Tokentextarea: Fix issues
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / docs / api / themes.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 Framework - Static Containers, States</title> 
7         <link rel="stylesheet"  href="../../css/themes/default/jquery.mobile.css" /> 
8         <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
9
10         <script src="../../js/jquery.js"></script>
11         <script src="../../docs/_assets/js/jqm-docs.js"></script>
12         <script src="../../js/"></script>
13
14 </head> 
15 <body> 
16
17 <div data-role="page" class="type-interior">
18
19         <div data-role="header" data-theme="f">
20                 <h1>Themes</h1>
21                 <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
22                 <a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
23         </div>
24
25         <div data-role="content">
26         
27         <div class="content-primary">
28                 <h2>Theming overview</h2>
29                 
30                         <p>The theming system used in jQuery Mobile is similar to the ThemeRoller system in jQuery UI with a few important improvements:</p> 
31
32                         <ul> 
33                                 <li>It takes advantage of <strong>CSS3 properties</strong> to add rounded corners, box and text shadow and gradients instead of images, allowing the theme file to be very lightweight and reducing server requests.</li>
34                                 <li>Themes include multiple <strong>color "swatches"</strong> &mdash; each consisting of a header bar, content body, and button states that can be freely mixed and matched to create visual texture &mdash; to make richer designs possible.</li> 
35                                 <li><strong>Open-ended theming</strong> allows for up to 26 unique swatches per theme, to add almost unlimited variety to designs.</li> 
36                                 <li>All backgrounds now use <strong>CSS3 gradients</strong> to dramatically reduce file size and number of server requests.</li> 
37                                 <li>There is a <strong>simplified icon set</strong> in a sprite to reduce image weight.</li> 
38                         </ul>
39                         
40                 <h2>ThemeRoller</h2>
41                 <a href="http://www.jquerymobile.com/themeroller" rel="external"><img src="../_assets/images/themroller-mobile-logo.png" width="250" style="float:right; margin-left:25px;" alt="Themroller Mobile Logo"></a>
42                 The easiest way to create custom themes is with the <a href="http://www.jquerymobile.com/themeroller" rel="external">ThemeRoller tool</a>. It allows you to build a theme, then download a custom CSS file, ready to be dropped into your project.
43                 
44                 <h2>Themes &amp; swatches</h2>
45                 
46                 <p>The theme system separates color and texture from structural styles that define things like padding and dimensions. This allows theme colors and textures to be defined once in the stylesheet and to be mixed, matched, and combined to achieve a wide range of visual effects. </p>
47                 
48                 <p>Each theme includes several global settings, including font family, drop shadows for overlays, and corner radius values for buttons and boxes. In addition, the theme can include multiple color swatches, each with color values for bars, content blocks, buttons and list items, and font <code>text-shadow</code>. </p>
49                 
50                 <p>The default theme includes 5 swatches that are given letters (a, b, c, d, e) for quick reference. To make mapping of color swatches consistent across our widgets, we have followed the convention that swatch "a" is the highest level of visual priority (black in our default theme), "b" is secondary level (blue) and "c" is the baseline level (gray) that we use by default in many situations, "d" for an alternate secondary level and "e" as an accent swatch.  Themes may have additional swatches for accent colors or specific situations. For example, you could add a new theme swatch "f" that has a red bar and button for use in error situations. </p>
51                 
52                 <p>Most theme changes can be done using ThemeRoller, but it's also simple to manually edit the base swatches in the default theme and/or add additional swatches by editing the theme CSS file. Just copy a block of swatch styles, rename the classes with the new swatch letter name, and tweak colors as you see fit.</p>
53                 
54                 
55                 <h3>Bars</h3>
56                 <p>The default theme contains the following five bar styles:</p>
57                 
58                 <div class="swatch-preview">
59                         <div class="ui-bar ui-bar-a">Bar A - <a href="#" data-role="none" class="ui-link">Link</a></div>
60                         <div class="ui-bar ui-bar-b">Bar B - <a href="#" data-role="none" class="ui-link">Link</a></div>
61                         <div class="ui-bar ui-bar-c">Bar C - <a href="#" data-role="none" class="ui-link">Link</a></div>
62                         <div class="ui-bar ui-bar-d">Bar D - <a href="#" data-role="none" class="ui-link">Link</a></div>
63                         <div class="ui-bar ui-bar-e">Bar E - <a href="#" data-role="none" class="ui-link">Link</a></div>
64                 </div><!-- end swatch-bars -->
65                 
66                 <p>By default, the framework assigns the "a" swatch to all headers and footers, because these are typically given high visual priority in an application. To set the color of a bar to a different swatch color, simply add the <code> data-theme</code> attribute to your header or footer and specify an alternate swatch letter ('b' or 'd', for example) and the specified theme swatch color will be applied. Learn more about <a href="../toolbars/bars-themes.html">toolbar theming</a>.</p>
67                 
68                 
69                 
70                 <h3>Content Blocks</h3>
71                 <p>The default theme also includes color swatch values for use in content blocks, designed to coordinate with the header color swatches in the theme. </p>
72                 
73                 <div class="swatch-preview">    
74                         <div class="ui-body ui-body-a">Block A - <a href="#">Link</a></div>
75                         <div class="ui-body ui-body-b">Block B - <a href="#">Link</a></div>
76                         <div class="ui-body ui-body-c">Block C - <a href="#">Link</a></div>
77                         <div class="ui-body ui-body-d">Block D - <a href="#">Link</a></div>
78                         <div class="ui-body ui-body-e">Block E - <a href="#">Link</a></div>
79                 </div><!-- end swatch-bars -->
80
81
82                 <p>If a theme isn't specified on a content block, the framework will default to "c" to maximize contrast against the default header "a", as shown here:</p>
83                                         
84                         <div data-role="header">
85                                 <a href="#" data-icon="arrow-l">Back</a>
86                                 <h1>Default Header</h1>
87                         </div>
88                         <div class="ui-body ui-body-c">
89                                 <h3>Default Theme Content Header</h3>
90                                 <p>This is the default content color swatch and a preview of a <a href="#" class="ui-link">link</a>.</p>
91                                         <label for="slider1">Input slider:</label>
92                                         <input type="range" name="slider1" id="slider1" value="50" min="0" max="100" />
93                                      <fieldset data-role="controlgroup"  data-type="horizontal" data-role="fieldcontain">
94                                         <legend>Cache settings:</legend>
95                                                 <input type="radio" name="radio-choice-a1" id="radio-choice-a1" value="on" checked="checked" />
96                                                 <label for="radio-choice-a1">On</label>
97                                                 <input type="radio" name="radio-choice-a1" id="radio-choice-b1" value="off"  />
98                                                 <label for="radio-choice-b1">Off</label>
99                                     </fieldset>
100                                 <a href="#" data-role="button" data-inline="true">Button</a>
101                         </div>
102                         <div class="ui-bar ui-bar-a">
103                                 <div data-role="controlgroup" data-type="horizontal" >
104                                         <a href="#" data-role="button" data-inline="true">Button</a><a href="#" data-role="button" data-inline="true">Button</a><a href="#" data-role="button" data-inline="true">Button</a>
105                                 </div><!-- /controlgroup -->
106                         </div>
107
108
109                 <p>Learn more about <a href="../content/content-themes.html">content theming</a>.</p>
110                 
111
112                 <h2>Lists &amp; Buttons</h2>
113                 <p>Each swatch also includes default styles for interactive elements like list items and buttons.</p>
114                 <ul data-role="listview" data-inset="true" data-theme="a">
115                         <li><a href="index.html">List item</a></li>
116                         <li><a href="index.html">List item</a></li>
117                 </ul>
118                 
119                 <ul data-role="listview" data-inset="true" data-theme="b">
120                         <li><a href="index.html">List item</a></li>
121                         <li><a href="index.html">List item</a></li>
122                 </ul>
123                 
124                 <ul data-role="listview" data-inset="true" data-theme="c">
125                         <li><a href="index.html">List item</a></li>
126                         <li><a href="index.html">List item</a></li>
127                 </ul>
128                 
129                 <ul data-role="listview" data-inset="true" data-theme="d">
130                         <li><a href="index.html">List item</a></li>
131                         <li><a href="index.html">List item</a></li>
132                 </ul>
133                 
134                 <ul data-role="listview" data-inset="true" data-theme="e">
135                         <li><a href="index.html">List item</a></li>
136                         <li><a href="index.html">List item</a></li>
137                 </ul>
138                 
139                 
140                 <p>A button is included for each swatch in the theme. Each button has styles for normal, hover/focus and pressed states.</p>
141                 
142                 <div class="swatch-preview">
143                         <a href="index.html" data-role="button" data-theme="a" data-icon="arrow-l">Button A</a>
144                         <a href="index.html" data-role="button" data-theme="b" data-icon="arrow-l">Button B</a>
145                         <a href="index.html" data-role="button" data-theme="c" data-icon="arrow-l">Button C</a>
146                         <a href="index.html" data-role="button" data-theme="d" data-icon="arrow-l">Button D</a>
147                         <a href="index.html" data-role="button" data-theme="e" data-icon="arrow-l">Button E</a>
148                 </div><!-- end swatch-bars -->
149                 
150                 
151                 <p>By default, any button that's placed in a bar is automatically assigned a swatch letter that matches its parent bar or content box. Thus, the button is visually integrated into the parent theme as shown here:</p>
152                 
153                 <div class="swatch-preview">
154                         <div data-role="header" data-theme="a"><h1>Bar A</h1><a href="index.html" data-icon="arrow-l">Button A</a></div>
155                         <div data-role="header" data-theme="b"><h1>Bar B</h1><a href="index.html" data-icon="arrow-l">Button B</a></div>
156                         <div data-role="header" data-theme="c"><h1>Bar C</h1><a href="index.html" data-icon="arrow-l">Button C</a></div>
157                         <div data-role="header" data-theme="d"><h1>Bar D</h1><a href="index.html" data-icon="arrow-l">Button D</a></div>
158                         <div data-role="header" data-theme="e"><h1>Bar E</h1><a href="index.html" data-icon="arrow-l">Button E</a></div>
159                 </div><!-- end swatch-bars -->
160                 
161                 <p>This default behavior makes it easy to ripple a theme change through a page by setting a theme swatch on a parent because you know the buttons will maintain the same relative visual weight across themes. Since form elements use the button styles, they will also adapt to their parent container.</p>
162                         
163                 <p>If you want to add visual emphasis to a button, an alternate swatch color can be set by adding a <code> data-theme="a"</code> to the anchor. Once an alternate swatch color is set on a button in the markup, the framework won't override that color if the parent theme is changed, because you made a conscious decision to set it.</p>
164                 
165                 <div class="swatch-bars">
166                         <div data-role="header" data-theme="a" class="ui-bar" >
167                                 <div><!-- wrapper div to have control over butttons -->
168                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
169                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
170                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
171                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
172                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
173                                 </div>
174                         </div>
175                         <div data-role="header" data-theme="b" class="ui-bar" >
176                                 <div><!-- wrapper div to have control over butttons -->
177                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
178                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
179                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
180                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
181                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
182                                 </div>
183                         </div>
184                         <div data-role="header" data-theme="c" class="ui-bar" >
185                                 <div><!-- wrapper div to have control over butttons -->
186                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
187                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
188                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
189                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
190                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
191                                 </div>
192                         </div>
193                         <div data-role="header" data-theme="d" class="ui-bar" >
194                                 <div><!-- wrapper div to have control over butttons -->
195                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
196                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
197                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
198                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
199                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
200                                 </div>
201                         </div>
202                         <div data-role="header" data-theme="e" class="ui-bar" >
203                                 <div><!-- wrapper div to have control over butttons -->
204                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
205                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
206                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
207                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
208                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
209                                 </div>
210                         </div>
211                         
212                 </div><!-- end swatch-bars -->
213
214 <p>Learn more about <a href="../lists/lists-themes.html">list theming</a> and <a href="../buttons/buttons-themes.html">button theming</a>.</p>
215
216                 <h3>Global "Active" state</h3>
217                 <p>The jQuery Mobile framework uses a swatch called "active" (bright blue in the default theme) to consistently indicate the selected state, regardless of the individual swatch of the given widget. We apply this in navigation and form controls whenever there is a need to indicate what is currently selected. Because this theme swatch is designed for clear, consistent user feedback, it cannot be overridden via the markup; it is set once in the theme and applied by the framework whenever a selected or active state is needed. The styling for this state is in the theme stylesheet under the <code>ui-btn-active</code> style rules.</p>
218                 
219                 <fieldset data-role="controlgroup"  data-type="horizontal" data-role="fieldcontain">
220                 <legend>Active is used for the on state of these toggles:</legend>
221                         <input type="radio" name=" radio-choice-a" id="radio-choice-a" value="on" checked="checked" />
222                         <label for="radio-choice-a">On</label>
223                         <input type="radio" name=" radio-choice-a" id="radio-choice-b" value="off"  />
224                         <label for="radio-choice-b">Off</label>
225             </fieldset>
226
227                 
228                 <h3>Icons</h3>
229                 <p>There is a core set of <a href="../buttons/buttons-icons.html">standard icons</a> included in the framework that can be assigned to any button. To minimize the download size of the core icons, jQuery Mobile only includes these icons in white and automatically adds a semi-transparent black circle behind the icon to make sure it has good contrast on all background colors.</p>
230
231                 <h3>Theme classes</h3>
232                 <p>Assigning color swatches through the <code> data-theme</code> attribute is one way to leverage the theme system, but it's also possible to apply any of the theme swatches directly to your markup through classes to apply the colors, textures and font formatting of your theme to any markup. This is especially useful when creating your own custom layout elements or UI widgets. Here are a few common theme classes, but many more are available in the theme stylesheet:</p>
233                 <dl>
234                         <dt><code>ui-bar-(a-z)</code></dt>
235                         <dd>Applies the toolbar theme styles for the selected swatch letter. Commonly used in conjunction with <code>ui-bar</code> structural class to add the standard bar padding styles.</dd>
236                         <dt><code>ui-body-(a-z)</code></dt>
237                         <dd>Applies the content body theme styles for the selected swatch letter. Commonly used in conjunction with <code>ui-body</code> structural class to add the standard content block padding styles. </dd>
238                         <dt><code>ui-btn-up-(a-z)</code></dt>
239                         <dd>Applies the button/clickable element theme styles for the selected swatch letter. Commonly used in with the <code>ui-btn-hover-(a-z)</code> and <code>ui-btn-down-(a-z)</code> interaction class states to provide visual feedback and <code>ui-btn-active</code> to indicate the selected or "on" state.</dd>
240                         <dt><code>ui-corner-all</code></dt>
241                         <dd>Applies the theme's global border-radius for rounded corners and is used for container or grouped items in the framework (inset lists, radiobutton sets). There are additional classes for all the possible combinations of rounded corners, for example: <code>ui-corner-tl</code> (top left only), <code>-top</code> (both top corners), <code>-left</code> (both left corners),  etc. A second full set of corner classes is provided for buttons so these can have a different corner radius. These use classes with a similar naming convention, but with "btn-corner" instead of "corner", like this: <code>.ui-<strong>btn-corner</strong>-all</code>.</dd>
242                         <dt><code>ui-shadow</code></dt>
243                         <dd>Applies the theme's global drop shadow to any element using CSS <code>box-shadow</code> property. </dd>
244                         <dt><code>ui-disabled</code></dt>
245                         <dd>Applies the disabled look and feel which essentially reduces the opacity of any element with this class to 30%, hides the cursor, and sets <code>pointer-events: none;</code> which prevents any interaction in many modern browsers.</dd>
246                 </dl>
247
248                         <h3>Overriding themes</h3>
249                         <p>The themes are meant as a solid starting point, but are meant to be customized. Since everything is controlled by CSS, it's easy to use a web inspector tool to identify the style properties you want to modify. The set of of theme classes (global) and semantic structural classes (widget-specific) added to elements provide a rich set of possible selectors to target style overrides against. We recommend adding an external stylesheet to the <code>head</code>, placed <strong>after</strong> the structure and theme stylesheet references, that contain all your style overrides. This allows you to easily update to newer versions of the library because overrides are kept separate from the library code.</p>
250                         
251                         
252                 <p><strong>Learn more</strong> about theming individual components:</p>
253                 <ul data-role="listview" data-inset="true">
254                         <li><a href="../pages/pages-themes.html">Page theming</a></li>
255                         <li><a href="../toolbars/bars-themes.html">Toolbar theming</a></li>
256                         <li><a href="../content/content-themes.html">Content theming</a></li>
257                         <li><a href="../buttons/buttons-themes.html">Button theming</a></li>
258             <li><a href="../forms/forms-themes.html">Form theming</a></li>
259             <li><a href="../lists/lists-themes.html">List theming</a></li>
260                 </ul>
261         </div><!--/content-secondary -->                
262         
263         <div class="content-secondary ui-body-d">
264                 
265                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
266                         
267                                 <h3>More in this section</h3>
268                                 
269                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
270                         
271                                         <li data-role="list-divider">API</li>
272                                         <li><a href="../../docs/api/globalconfig.html">Configuring defaults</a></li>
273                                         <li><a href="../../docs/api/events.html">Events</a></li>
274                                         <li><a href="../../docs/api/methods.html">Methods &amp; Utilities</a></li>
275                                         <li><a href="../../docs/api/data-attributes.html">Data attribute reference</a></li>
276                                         <li data-theme="a"><a href="../../docs/api/themes.html">Theme framework</a></li>
277         
278                                         </ul>
279                 </div>
280         </div>          
281
282 </div><!-- /content -->
283
284 <div data-role="footer" class="footer-docs" data-theme="c">
285                 <p>&copy; 2011-12 The jQuery Foundation</p>
286 </div>
287         
288 </div><!-- /page -->
289
290 </body>
291 </html>