Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / 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/" /> 
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>Themes</h1>
20                 <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21         </div>
22
23         <div data-role="content">
24         
25         <div class="content-primary">
26                 <h2>Theming overview</h2>
27                 
28                         <p>Every layout and widget in jQuery Mobile is designed around a new object-oriented CSS framework that makes it possible to apply a complete unified visual design Theme to sites and applications. The theming system is similar to the ThemeRoller system in jQuery UI, but adds a few important improvements:</p> 
29
30                         <ul> 
31                                 <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>
32                                 <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> 
33                                 <li><strong>Open-ended theming</strong> allows for up to 26 unique swatches per theme, to add almost unlimited variety to designs</li> 
34                                 <li>All backgrounds now use <strong>CSS3 gradients</strong> to dramatically reduce file size and number of server requests</li> 
35                                 <li>A <strong>simplified icon set</strong> including those most commonly used for mobile, in a sprite to reduce image weight</li> 
36                         </ul>
37                         
38                 <h2>ThemeRoller</h2>
39                 <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>
40                 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.
41                 
42                 <h2>Themes &amp; swatches</h2>
43                 
44                 <p>The key to the Theme system is separation of 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 be mixed, matched and combined to achieve a wide range of visual effects. </p>
45                 
46                 <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>
47                 
48                 <p>jQuery Mobile's 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>
49                 
50                 <p>A new ThemeRoller tool will launched with the jQuery Mobile 1.0 release in 2011. In the meantime, it's simple to manually edit the base swatches in the default theme and/or add additional swatches by editing the theme css file: copy a block of swatch styles, rename the classes with the new swatch letter name, and tweak colors.</p>
51                 
52                 
53                 <h3>Bars</h3>
54                 <p>The default theme contains the following five Bar styles:</p>
55                 
56                 <div class="swatch-preview">
57                         <div class="ui-bar ui-bar-a">Bar A - <a href="#" data-role="none" class="ui-link">Link</a></div>
58                         <div class="ui-bar ui-bar-b">Bar B - <a href="#" data-role="none" class="ui-link">Link</a></div>
59                         <div class="ui-bar ui-bar-c">Bar C - <a href="#" data-role="none" class="ui-link">Link</a></div>
60                         <div class="ui-bar ui-bar-d">Bar D - <a href="#" data-role="none" class="ui-link">Link</a></div>
61                         <div class="ui-bar ui-bar-e">Bar E - <a href="#" data-role="none" class="ui-link">Link</a></div>
62                 </div><!-- end swatch-bars -->
63                 
64                 <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>
65                 
66                 
67                 
68                 <h3>Content Blocks</h3>
69                 <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>
70                 
71                 <div class="swatch-preview">    
72                         <div class="ui-body ui-body-a">Block A - <a href="#">Link</a></div>
73                         <div class="ui-body ui-body-b">Block B - <a href="#">Link</a></div>
74                         <div class="ui-body ui-body-c">Block C - <a href="#">Link</a></div>
75                         <div class="ui-body ui-body-d">Block D - <a href="#">Link</a></div>
76                         <div class="ui-body ui-body-e">Block E - <a href="#">Link</a></div>
77                 </div><!-- end swatch-bars -->
78
79
80                 <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>
81                                         
82                         <div data-role="header" data-position="inline">
83                                 <a href="#" data-icon="arrow-l">Back</a>
84                                 <h1>Default Header</h1>
85                         </div>
86                         <div class="ui-body ui-body-c">
87                                 <h3>Default Theme Content Header</h3>
88                                 <p>This is the default content color swatch and a preview of a <a href="#" class="ui-link">link</a>.</p>
89                                         <label for="slider1">Input slider:</label>
90                                         <input type="range" name="slider1" id="slider1" value="50" min="0" max="100" />
91                                      <fieldset data-role="controlgroup"  data-type="horizontal" data-role="fieldcontain">
92                                         <legend>Cache settings:</legend>
93                                                 <input type="radio" name="radio-choice-a1" id="radio-choice-a1" value="on" checked="checked" />
94                                                 <label for="radio-choice-a1">On</label>
95                                                 <input type="radio" name="radio-choice-a1" id="radio-choice-b1" value="off"  />
96                                                 <label for="radio-choice-b1">Off</label>
97                                     </fieldset>
98                                 <a href="#" data-role="button" data-inline="true">Button</a>
99                         </div>
100                         <div class="ui-bar ui-bar-a">
101                                 <div data-role="controlgroup" data-type="horizontal" >
102                                         <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>
103                                 </div><!-- /controlgroup -->
104                         </div>
105
106
107                 <p>Learn more about <a href="../content/content-themes.html">content theming</a>.</p>
108                 
109
110                 <h2>Lists &amp; Buttons</h2>
111                 <p>Each swatch also includes default styles for interactive elements like list items and buttons.</p>
112                 <ul data-role="listview" data-inset="true" data-theme="a">
113                         <li><a href="index.html">List item</a></li>
114                         <li><a href="index.html">List item</a></li>
115                 </ul>
116                 
117                 <ul data-role="listview" data-inset="true" data-theme="b">
118                         <li><a href="index.html">List item</a></li>
119                         <li><a href="index.html">List item</a></li>
120                 </ul>
121                 
122                 <ul data-role="listview" data-inset="true" data-theme="c">
123                         <li><a href="index.html">List item</a></li>
124                         <li><a href="index.html">List item</a></li>
125                 </ul>
126                 
127                 <ul data-role="listview" data-inset="true" data-theme="d">
128                         <li><a href="index.html">List item</a></li>
129                         <li><a href="index.html">List item</a></li>
130                 </ul>
131                 
132                 <ul data-role="listview" data-inset="true" data-theme="e">
133                         <li><a href="index.html">List item</a></li>
134                         <li><a href="index.html">List item</a></li>
135                 </ul>
136                 
137                 
138                 <p>A button is included for each swatch in the theme. Each button has styles for normal, hover/focus and pressed states.</p>
139                 
140                 <div class="swatch-preview">
141                         <a href="index.html" data-role="button" data-theme="a" data-icon="arrow-l">Button A</a>
142                         <a href="index.html" data-role="button" data-theme="b" data-icon="arrow-l">Button B</a>
143                         <a href="index.html" data-role="button" data-theme="c" data-icon="arrow-l">Button C</a>
144                         <a href="index.html" data-role="button" data-theme="d" data-icon="arrow-l">Button D</a>
145                         <a href="index.html" data-role="button" data-theme="e" data-icon="arrow-l">Button E</a>
146                 </div><!-- end swatch-bars -->
147                 
148                 
149                 <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, to visually integrate the button into the parent theme like a chameleon, as shown here:</p>
150                 
151                 <div class="swatch-preview">
152                         <div data-role="header" data-theme="a"><h1>Bar A</h1><a href="index.html" data-icon="arrow-l">Button A</a></div>
153                         <div data-role="header" data-theme="b"><h1>Bar B</h1><a href="index.html" data-icon="arrow-l">Button B</a></div>
154                         <div data-role="header" data-theme="c"><h1>Bar C</h1><a href="index.html" data-icon="arrow-l">Button C</a></div>
155                         <div data-role="header" data-theme="d"><h1>Bar D</h1><a href="index.html" data-icon="arrow-l">Button D</a></div>
156                         <div data-role="header" data-theme="e"><h1>Bar E</h1><a href="index.html" data-icon="arrow-l">Button E</a></div>
157                 </div><!-- end swatch-bars -->
158                 
159                 <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 too. </p>
160                         
161                 <p>If you want to add visual emphasis to a button and help it stand out visually from its parent toolbar, 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>
162                 
163                 <div class="swatch-bars">
164                         <div data-role="header" data-theme="a" class="ui-bar" >
165                                 <div><!-- wrapper div to have control over butttons -->
166                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
167                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
168                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
169                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
170                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
171                                 </div>
172                         </div>
173                         <div data-role="header" data-theme="b" class="ui-bar" >
174                                 <div><!-- wrapper div to have control over butttons -->
175                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
176                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
177                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
178                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
179                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
180                                 </div>
181                         </div>
182                         <div data-role="header" data-theme="c" class="ui-bar" >
183                                 <div><!-- wrapper div to have control over butttons -->
184                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
185                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
186                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
187                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
188                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
189                                 </div>
190                         </div>
191                         <div data-role="header" data-theme="d" class="ui-bar" >
192                                 <div><!-- wrapper div to have control over butttons -->
193                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
194                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
195                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
196                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
197                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
198                                 </div>
199                         </div>
200                         <div data-role="header" data-theme="e" class="ui-bar" >
201                                 <div><!-- wrapper div to have control over butttons -->
202                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="a">A</a>
203                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="b">B</a>
204                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="c">C</a>
205                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="d">D</a>
206                                         <a href="index.html" data-role="button" data-icon="arrow-l" data-theme="e">E</a>
207                                 </div>
208                         </div>
209                         
210                 </div><!-- end swatch-bars -->
211
212 <p>Learn more about <a href="../lists/lists-themes.html">list theming</a> and <a href="../buttons/buttons-themes.html">button theming</a>.</p>
213
214                 <h3>Global "Active" state</h3>
215                 <p>The jQuery Mobile framework uses a single Theme-level 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>
216                 
217                 <fieldset data-role="controlgroup"  data-type="horizontal" data-role="fieldcontain">
218                 <legend>Active is used for the on state of these toggles:</legend>
219                         <input type="radio" name=" radio-choice-a" id="radio-choice-a" value="on" checked="checked" />
220                         <label for="radio-choice-a">On</label>
221                         <input type="radio" name=" radio-choice-a" id="radio-choice-b" value="off"  />
222                         <label for="radio-choice-b">Off</label>
223             </fieldset>
224
225                 
226                 <h3>Icons</h3>
227                 <p>There 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>
228
229                 <h3>Theme classes</h3>
230                 <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>
231                 <dl>
232                         <dt><code>ui-bar-(a-z)</code></dt>
233                         <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>
234                         <dt><code>ui-body-(a-z)</code></dt>
235                         <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>
236                         <dt><code>ui-btn-up-(a-z)</code></dt>
237                         <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>
238                         <dt><code>ui-corner-all</code></dt>
239                         <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>
240                         <dt><code>ui-shadow</code></dt>
241                         <dd>Applies the theme's global drop shadow to any element using CSS <code>box-shadow</code> property. </dd>
242                         <dt><code>ui-disabled</code></dt>
243                         <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>
244                 </dl>
245
246                         <h3>Overriding themes</h3>
247                         <p>The themes are meant as a solid starting point, but are meant to be customized to add the custom design elements that make your site or app unique. 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>
248                         
249                         
250                 <p><strong>Learn more</strong> about theming individual components:</p>
251                 <ul data-role="listview" data-inset="true">
252                         <li><a href="../pages/pages-themes.html">Page theming</a></li>
253                         <li><a href="../toolbars/bars-themes.html">Toolbar theming</a></li>
254                         <li><a href="../content/content-themes.html">Content theming</a></li>
255                         <li><a href="../buttons/buttons-themes.html">Button theming</a></li>
256             <li><a href="../forms/forms-themes.html">Form theming</a></li>
257             <li><a href="../lists/lists-themes.html">List theming</a></li>
258                 </ul>
259         </div><!--/content-secondary -->                
260         
261         <div class="content-secondary ui-body-d">
262                 
263                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
264                         
265                                 <h3>More in this section</h3>
266                                 
267                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
268                         
269                                         <li data-role="list-divider">API</li>
270                                         <li><a href="../../docs/api/globalconfig.html">Configuring defaults</a></li>
271                                         <li><a href="../../docs/api/events.html">Events</a></li>
272                                         <li><a href="../../docs/api/methods.html">Methods &amp; Utilities</a></li>
273                                         <li><a href="../../docs/api/data-attributes.html">Data attribute reference</a></li>
274                                         <li data-theme="a"><a href="../../docs/api/themes.html">Theme framework</a></li>
275         
276                                         </ul>
277                 </div>
278         </div>          
279
280 </div><!-- /content -->
281
282 <div data-role="footer" class="footer-docs" data-theme="c">
283                 <p>&copy; 2011 The jQuery Project</p>
284 </div>
285         
286 </div><!-- /page -->
287
288 </body>
289 </html>