f148112d0d99e389da1eb1fb8896153e45fcb903
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / docs / buttons / buttons-icons.html
1 <!DOCTYPE html> 
2 <html> 
3         <head>
4         <meta charset="utf-8">
5         <meta name="viewport" content="width=device-width, initial-scale=1"> 
6         <title>jQuery Mobile Docs - Button icons</title> 
7         <link rel="stylesheet"  href="../../css/themes/default/" />  
8         <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
9         <script src="../../js/jquery.js"></script>
10         <script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11         <script src="../_assets/js/jqm-docs.js"></script>
12         <script src="../../js/"></script>
13 </head> 
14 <body> 
15
16 <div data-role="page" class="type-interior">
17
18         <div data-role="header" data-theme="f">
19                 <h1>Button icons</h1>
20                 <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21         </div><!-- /header -->
22
23         <div data-role="content">
24                 <div class="content-primary">
25                 
26                 <h2>Adding Icons to Buttons</h2>
27                 <p>The jQuery Mobile framework includes a selected set of icons most often needed for mobile apps. To minimize download size, jQuery Mobile includes a single white icon sprite, and automatically adds a semi-transparent black circle behind the icon to ensure that it has good contrast on any background color.</p> 
28                 
29                         
30                         <p>An icon can be added to a button by adding a <code> data-icon</code> attribute on the anchor specifying the icon to display.  For example, the following markup:</p> 
31                         
32                         <code>
33                         &lt;a href=&quot;index.html&quot; data-role=&quot;button&quot; <strong> data-icon=&quot;delete&quot;</strong>&gt;Delete&lt;/a&gt;
34                         </code>
35                         
36                         <p>Creates this button with an icon:</p>
37                         <a href="index.html" data-role="button" data-icon="delete">Delete</a>
38                         
39                         <h2>Icon set</h2>
40                         
41                         <p>The following <code> data-icon</code> attributes can be referenced to create the icons shown below:</p>
42                         
43                         <p><strong>Left arrow</strong> - data-icon="arrow-l"</p>
44                         <a href="index.html" data-role="button" data-icon="arrow-l">My button</a>
45                         <p><strong>Right arrow</strong> - data-icon="arrow-r"</p>
46                         <a href="index.html" data-role="button" data-icon="arrow-r">My button</a>
47                         <p><strong>Up arrow</strong> - data-icon="arrow-u"</p>
48                         <a href="index.html" data-role="button" data-icon="arrow-u">My button</a>
49                         <p><strong>Down arrow</strong> - data-icon="arrow-d"</p>
50                         <a href="index.html" data-role="button" data-icon="arrow-d">My button</a>
51                         <p><strong>Delete</strong> - data-icon="delete"</p>
52                         <a href="index.html" data-role="button" data-icon="delete">My button</a>
53                         <p><strong>Plus</strong> - data-icon="plus"</p>
54                         <a href="index.html" data-role="button" data-icon="plus">My button</a>
55                         <p><strong>Minus</strong> - data-icon="minus"</p>
56                         <a href="index.html" data-role="button" data-icon="minus">My button</a>
57                         <p><strong>Check</strong> - data-icon="check"</p>
58                         <a href="index.html" data-role="button" data-icon="check">My button</a>
59                         <p><strong>Gear</strong> - data-icon="gear"</p>
60                         <a href="index.html" data-role="button" data-icon="gear">My button</a>
61                         <p><strong>Refresh</strong> - data-icon="refresh"</p>
62                         <a href="index.html" data-role="button" data-icon="refresh">My button</a>
63                         <p><strong>Forward</strong> - data-icon="forward"</p>
64                         <a href="index.html" data-role="button" data-icon="forward">My button</a>
65                         <p><strong>Back</strong> - data-icon="back"</p>
66                         <a href="index.html" data-role="button" data-icon="back">My button</a>
67                         <p><strong>Grid</strong> - data-icon="grid"</p>
68                         <a href="index.html" data-role="button" data-icon="grid">My button</a>
69                         <p><strong>Star</strong> - data-icon="star"</p>
70                         <a href="index.html" data-role="button" data-icon="star">My button</a>
71                         <p><strong>Alert</strong> - data-icon="alert"</p>
72                         <a href="index.html" data-role="button" data-icon="alert">My button</a>
73                         <p><strong>Info</strong> - data-icon="info"</p>
74                         <a href="index.html" data-role="button" data-icon="info">My button</a>
75                         <p><strong>Home</strong> - data-icon="home"</p>
76                         <a href="index.html" data-role="button" data-icon="home">My button</a>
77                         <p><strong>Search</strong> - data-icon="search"</p>
78                         <a href="index.html" data-role="button" data-icon="search">My button</a>
79                         
80
81                 <h2>Icon positioning</h2>
82                 <p>By default, all icons in buttons are placed to the left of the button text. </p>
83                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="left">Delete</a>
84                 
85                 <p>This default may be overridden using the <code> data-iconpos</code> attribute to set the icon to the right, above (top) or below (bottom) the text. For example, the markup:</p> 
86
87 <code>
88 &lt;a href=&quot;index.html&quot; data-role=&quot;button&quot; data-icon=&quot;delete&quot;<strong> data-iconpos=&quot;right&quot;</strong>&gt;Delete&lt;/a&gt;
89 </code>
90
91                 <p>Creates this button with right-aligned icon:</p>
92                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="right">Delete</a>
93
94                 <p>Icons can also be positioned above the text by specifying <code> data-iconpos="top"</code></p>
95                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="top">Delete</a>
96                 
97                 <p>Or icons can also be positioned below the text by specifying <code> data-iconpos="bottom"</code></p>
98                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="bottom">Delete</a>
99                 
100                 <p>You can also create an icon-only button, by setting the <code> data-iconpos</code> attribute to <code>notext</code>. The button plugin will hide the text on-screen, but add it as a <code>title</code> attribute on the link to provide context for screen readers and devices that support tooltips. For example, replacing <code> data-iconpos="right"</code> on the previous example with <code> data-iconpos="notext"</code>:</p>
101
102 <code>
103 &lt;a href=&quot;index.html&quot; data-role=&quot;button&quot; data-icon=&quot;delete&quot;<strong> data-iconpos=&quot;notext&quot;</strong>&gt;Delete&lt;/a&gt;
104 </code>
105
106                 <p>Creates this icon-only button:</p>
107                         <a href="index.html" data-role="button" data-icon="delete" data-iconpos="notext">Delete</a>
108
109                 <h2>Custom Icons</h2>
110                 <p>To use custom icons, specify a <code>data-icon</code> value that has a unique name like <code>myapp-email</code> and the button plugin will generate a class by prefixing <code>ui-icon-</code> to the <code> data-icon</code> value and apply it to the button: <code>ui-icon-myapp-email</code>. </p>
111                 <p>You can then write a CSS rule in your stylesheet that targets the <code>ui-icon-myapp-email</code> class to specify the icon background source. To maintain visual consistency with the rest of the icons, create a white icon 18x18 pixels saved as a PNG-8 with alpha transparency.</p>
112                 <p> In this example, we're just pointing to a standalone icon image, but you could just as easily use an icon sprite and specify the positioning instead, just like the icon sprite we use in the framework.</p>
113                 
114 <pre><code>.ui-icon-myapp-email {
115         background-image: url("app-icon-email.png");
116 }</code></pre>
117
118                 <p>This will create the standard resolution icon, but many devices now have very high resolution displays, like the retina display on the iPhone 4. To add a HD icon, create an icon that is 36x36 pixels (exactly double the 18 pixel size), and add second rule that uses the <code>-webkit-min-device-pixel-ratio: 2</code> media query to target a rule only to high resolution displays. Specify the background image for the HD icon file and set the background size to 18x18 pixels which will fit the 36 pixel icon into the same 18 pixel space. The media query block can wrap multiple icon rules:</p>
119 <pre><code>
120 @media only screen and (-webkit-min-device-pixel-ratio: 2) {
121         .ui-icon-myapp-email {
122                 background-image: url("app-icon-email-highres.png");
123                 background-size: 18px 18px;
124         }
125         ...more HD icon rules go here...
126 }
127 </code></pre>                   
128                         
129                 <h2>Icons and themes</h2>
130                 <p>The semi-transparent black circle behind the white icon ensures good contrast on any background color so it works well with the jQuery Mobile theming system. Here are examples of the same icons sitting on top of a range of different color swatches in out theme.</p>
131                 
132                 <!-- A themed -->
133                 <p><strong>Swatch "A"</strong> themed buttons</p>
134                 <div data-role="controlgroup"  data-type="horizontal">
135                 <a href="index.html" data-role="button" data-icon="arrow-l" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
136                 <a href="index.html" data-role="button" data-icon="arrow-r" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
137                 <a href="index.html" data-role="button" data-icon="arrow-u" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
138                 <a href="index.html" data-role="button" data-icon="arrow-d" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
139                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
140                 <a href="index.html" data-role="button" data-icon="plus" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
141                 <a href="index.html" data-role="button" data-icon="minus" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
142                 <a href="index.html" data-role="button" data-icon="check" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
143                 <a href="index.html" data-role="button" data-icon="gear" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
144                 <a href="index.html" data-role="button" data-icon="refresh" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
145                 <a href="index.html" data-role="button" data-icon="forward" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
146                 <a href="index.html" data-role="button" data-icon="back" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
147                 <a href="index.html" data-role="button" data-icon="grid" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
148                 <a href="index.html" data-role="button" data-icon="star" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
149                 <a href="index.html" data-role="button" data-icon="alert" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
150                 <a href="index.html" data-role="button" data-icon="info" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
151         <a href="index.html" data-role="button" data-icon="home" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
152         <a href="index.html" data-role="button" data-icon="search" data-iconpos="notext" data-theme="a" data-inline="true">My button</a>
153                 </div>
154                 
155                 <!-- B themed -->
156                 <p><strong>Swatch "B"</strong> themed buttons</p>
157                 <div data-role="controlgroup"  data-type="horizontal">
158                 <a href="index.html" data-role="button" data-icon="arrow-l" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
159                 <a href="index.html" data-role="button" data-icon="arrow-r" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
160                 <a href="index.html" data-role="button" data-icon="arrow-u" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
161                 <a href="index.html" data-role="button" data-icon="arrow-d" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
162                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
163                 <a href="index.html" data-role="button" data-icon="plus" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
164                 <a href="index.html" data-role="button" data-icon="minus" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
165                 <a href="index.html" data-role="button" data-icon="check" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
166                 <a href="index.html" data-role="button" data-icon="gear" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
167                 <a href="index.html" data-role="button" data-icon="refresh" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
168                 <a href="index.html" data-role="button" data-icon="forward" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
169                 <a href="index.html" data-role="button" data-icon="back" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
170                 <a href="index.html" data-role="button" data-icon="grid" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
171                 <a href="index.html" data-role="button" data-icon="star" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
172                 <a href="index.html" data-role="button" data-icon="alert" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
173                 <a href="index.html" data-role="button" data-icon="info" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
174         <a href="index.html" data-role="button" data-icon="home" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
175         <a href="index.html" data-role="button" data-icon="search" data-iconpos="notext" data-theme="b" data-inline="true">My button</a>
176                 </div>
177                 
178                 <!-- C themed -->
179                 <p><strong>Swatch "C"</strong> themed buttons</p>
180                 <div data-role="controlgroup"  data-type="horizontal">
181                 <a href="index.html" data-role="button" data-icon="arrow-l" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
182                 <a href="index.html" data-role="button" data-icon="arrow-r" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
183                 <a href="index.html" data-role="button" data-icon="arrow-u" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
184                 <a href="index.html" data-role="button" data-icon="arrow-d" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
185                 <a href="index.html" data-role="button" data-icon="delete" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
186                 <a href="index.html" data-role="button" data-icon="plus" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
187                 <a href="index.html" data-role="button" data-icon="minus" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
188                 <a href="index.html" data-role="button" data-icon="check" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
189                 <a href="index.html" data-role="button" data-icon="gear" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
190                 <a href="index.html" data-role="button" data-icon="refresh" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
191                 <a href="index.html" data-role="button" data-icon="forward" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
192                 <a href="index.html" data-role="button" data-icon="back" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
193                 <a href="index.html" data-role="button" data-icon="grid" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
194                 <a href="index.html" data-role="button" data-icon="star" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
195                 <a href="index.html" data-role="button" data-icon="alert" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
196                 <a href="index.html" data-role="button" data-icon="info" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
197         <a href="index.html" data-role="button" data-icon="home" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
198         <a href="index.html" data-role="button" data-icon="search" data-iconpos="notext" data-theme="c" data-inline="true">My button</a>
199                 </div>
200         
201         </div><!--/content-primary -->          
202         
203         <div class="content-secondary">
204                 
205                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
206                         
207                                 <h3>More in this section</h3>
208                                 
209                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
210                                 
211                                         <li data-role="list-divider">Buttons</li>
212                                         <li><a href="buttons-types.html">Button basics</a></li>
213                                         <li data-theme="a"><a href="buttons-icons.html">Button icons</a></li>
214                                         <li><a href="buttons-inline.html">Inline buttons</a></li>
215                                         <li><a href="buttons-grouped.html">Grouped buttons</a></li>
216                                         <li><a href="buttons-themes.html">Theming buttons</a></li>
217         
218                                 </ul>
219                 </div>
220         </div>          
221
222 </div><!-- /content -->
223
224 <div data-role="footer" class="footer-docs" data-theme="c">
225                 <p>&copy; 2011 The jQuery Project</p>
226 </div>
227         
228 </div><!-- /page -->
229
230 </body>
231 </html>