5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery Mobile Docs - Theming Forms</title>
7 <link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
8 <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
10 <script src="../../js/jquery.js"></script>
11 <script src="../../docs/_assets/js/jqm-docs.js"></script>
12 <script src="../../js/"></script>
17 <div data-role="page" class="type-interior">
19 <div data-role="header" data-theme="f">
20 <h1>Theming forms</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><!-- /header -->
25 <div data-role="content">
26 <div class="content-primary">
29 <p>jQuery Mobile has a rich <a href="../api/themes.html">theming system</a> that gives you full control of how pages and forms are styled. By default all form elements inside a container will automatically adopt the same theme color swatch as their parent. This allows form elements to blend into their layouts with minimal work. The <code> data-theme</code> attribute can be applied to any individual form element to apply any of the lettered theme color swatches to create contrast and emphasis in your designs.</p>
31 <p>All the form elements in the examples below use the same HTML code with no theme swatch specified on the individual form elements. The only difference between each example block code is a <code> data-theme</code> swatch color assigned to each parent container. This illustrates the way form elements automatically adopt the theme swatch of their parent.</p>
34 <h2>Body swatch A</h2>
35 <div class="ui-body ui-body-a">
37 <div data-role="fieldcontain">
38 <label for="name-a">Text Input:</label>
39 <input type="text" name="name" id="name-a" value="" />
42 <div data-role="fieldcontain">
43 <label for="switch-a">Flip switch:</label>
44 <select name="switch-a" id="switch-a" data-role="slider">
45 <option value="off">Off</option>
46 <option value="on">On</option>
50 <div data-role="fieldcontain">
51 <label for="slider-a">Slider:</label>
52 <input type="range" name="slider" id="slider-a" value="0" min="0" max="100" />
56 <div data-role="fieldcontain">
57 <fieldset data-role="controlgroup" data-type="horizontal">
58 <legend>Font styling:</legend>
59 <input type="checkbox" name="checkbox-6a" id="checkbox-6a" class="custom" />
60 <label for="checkbox-6a">b</label>
62 <input type="checkbox" name="checkbox-7a" id="checkbox-7a" class="custom" />
63 <label for="checkbox-7a"><em>i</em></label>
65 <input type="checkbox" name="checkbox-8a" id="checkbox-8a" class="custom" />
66 <label for="checkbox-8a">u</label>
70 <div data-role="fieldcontain">
71 <fieldset data-role="controlgroup">
72 <legend>Choose a pet:</legend>
73 <input type="radio" name="radio-choice-1" id="radio-choice-1a" value="choice-1" />
74 <label for="radio-choice-1a">Cat</label>
76 <input type="radio" name="radio-choice-1" id="radio-choice-2a" value="choice-2" />
77 <label for="radio-choice-2a">Dog</label>
79 <input type="radio" name="radio-choice-1" id="radio-choice-3a" value="choice-3" />
80 <label for="radio-choice-3a">Hamster</label>
82 <input type="radio" name="radio-choice-1" id="radio-choice-4a" value="choice-4" />
83 <label for="radio-choice-4a">Lizard</label>
87 <div data-role="fieldcontain">
88 <label for="select-choice-a" class="select">Choose shipping method:</label>
89 <select name="select-choice-a" id="select-choice-a">
90 <option value="standard">Standard: 7 day</option>
91 <option value="rush">Rush: 3 days</option>
92 <option value="express">Express: next day</option>
93 <option value="overnight">Overnight</option>
97 </div><!-- /body-a -->
99 <h2>Body swatch B</h2>
100 <div class="ui-body ui-body-b">
102 <div data-role="fieldcontain">
103 <label for="name-b">Text Input:</label>
104 <input type="text" name="name" id="name-b" value="" />
107 <div data-role="fieldcontain">
108 <label for="switch-b">Flip switch:</label>
109 <select name="switch-b" id="switch-b" data-role="slider">
110 <option value="off">Off</option>
111 <option value="on">On</option>
115 <div data-role="fieldcontain">
116 <label for="slider-b">Slider:</label>
117 <input type="range" name="slider" id="slider-b" value="0" min="0" max="100" />
121 <div data-role="fieldcontain">
122 <fieldset data-role="controlgroup" data-type="horizontal">
123 <legend>Font styling:</legend>
124 <input type="checkbox" name="checkbox-6b" id="checkbox-6b" class="custom" />
125 <label for="checkbox-6b">b</label>
127 <input type="checkbox" name="checkbox-7b" id="checkbox-7b" class="custom" />
128 <label for="checkbox-7b"><em>i</em></label>
130 <input type="checkbox" name="checkbox-8b" id="checkbox-8b" class="custom" />
131 <label for="checkbox-8b">u</label>
135 <div data-role="fieldcontain">
136 <fieldset data-role="controlgroup">
137 <legend>Choose a pet:</legend>
138 <input type="radio" name="radio-choice-1" id="radio-choice-1b" value="choice-1" />
139 <label for="radio-choice-1b">Cat</label>
141 <input type="radio" name="radio-choice-1" id="radio-choice-2b" value="choice-2" />
142 <label for="radio-choice-2b">Dog</label>
144 <input type="radio" name="radio-choice-1" id="radio-choice-3b" value="choice-3" />
145 <label for="radio-choice-3b">Hamster</label>
147 <input type="radio" name="radio-choice-1" id="radio-choice-4b" value="choice-4" />
148 <label for="radio-choice-4b">Lizard</label>
152 <div data-role="fieldcontain">
153 <label for="select-choice-b" class="select">Choose shipping method:</label>
154 <select name="select-choice-b" id="select-choice-b">
155 <option value="standard">Standard: 7 day</option>
156 <option value="rush">Rush: 3 days</option>
157 <option value="express">Express: next day</option>
158 <option value="overnight">Overnight</option>
163 </div><!-- /body-b -->
166 <h2>Body swatch C</h2>
167 <div class="ui-body ui-body-c">
169 <div data-role="fieldcontain">
170 <label for="name-c">Text Input:</label>
171 <input type="text" name="name" id="name-c" value="" />
174 <div data-role="fieldcontain">
175 <label for="switch-c">Flip switch:</label>
176 <select name="switch-c" id="switch-c" data-role="slider">
177 <option value="off">Off</option>
178 <option value="on">On</option>
182 <div data-role="fieldcontain">
183 <label for="slider-c">Slider:</label>
184 <input type="range" name="slider" id="slider-c" value="0" min="0" max="100" />
188 <div data-role="fieldcontain">
189 <fieldset data-role="controlgroup" data-type="horizontal">
190 <legend>Font styling:</legend>
191 <input type="checkbox" name="checkbox-6c" id="checkbox-6c" class="custom" />
192 <label for="checkbox-6c">b</label>
194 <input type="checkbox" name="checkbox-7c" id="checkbox-7c" class="custom" />
195 <label for="checkbox-7c"><em>i</em></label>
197 <input type="checkbox" name="checkbox-8c" id="checkbox-8c" class="custom" />
198 <label for="checkbox-8c">u</label>
202 <div data-role="fieldcontain">
203 <fieldset data-role="controlgroup">
204 <legend>Choose a pet:</legend>
205 <input type="radio" name="radio-choice-1" id="radio-choice-1c" value="choice-1" />
206 <label for="radio-choice-1c">Cat</label>
208 <input type="radio" name="radio-choice-1" id="radio-choice-2c" value="choice-2" />
209 <label for="radio-choice-2c">Dog</label>
211 <input type="radio" name="radio-choice-1" id="radio-choice-3c" value="choice-3" />
212 <label for="radio-choice-3c">Hamster</label>
214 <input type="radio" name="radio-choice-1" id="radio-choice-4c" value="choice-4" />
215 <label for="radio-choice-4c">Lizard</label>
219 <div data-role="fieldcontain">
220 <label for="select-choice-c" class="select">Choose shipping method:</label>
221 <select name="select-choice-c" id="select-choice-c">
222 <option value="standard">Standard: 7 day</option>
223 <option value="rush">Rush: 3 days</option>
224 <option value="express">Express: next day</option>
225 <option value="overnight">Overnight</option>
230 </div><!-- /body-c -->
234 <h2>Body swatch D</h2>
235 <div class="ui-body ui-body-d">
237 <div data-role="fieldcontain">
238 <label for="name-d">Text Input:</label>
239 <input type="text" name="name" id="name-d" value="" />
242 <div data-role="fieldcontain">
243 <label for="switch-d">Flip switch:</label>
244 <select name="switch-d" id="switch-d" data-role="slider">
245 <option value="off">Off</option>
246 <option value="on">On</option>
250 <div data-role="fieldcontain">
251 <label for="slider-d">Slider:</label>
252 <input type="range" name="slider" id="slider-d" value="0" min="0" max="100" />
256 <div data-role="fieldcontain">
257 <fieldset data-role="controlgroup" data-type="horizontal">
258 <legend>Font styling:</legend>
259 <input type="checkbox" name="checkbox-6d" id="checkbox-6d" class="custom" />
260 <label for="checkbox-6d">b</label>
262 <input type="checkbox" name="checkbox-7d" id="checkbox-7d" class="custom" />
263 <label for="checkbox-7d"><em>i</em></label>
265 <input type="checkbox" name="checkbox-8d" id="checkbox-8d" class="custom" />
266 <label for="checkbox-8d">u</label>
270 <div data-role="fieldcontain">
271 <fieldset data-role="controlgroup">
272 <legend>Choose a pet:</legend>
273 <input type="radio" name="radio-choice-1" id="radio-choice-1d" value="choice-1" />
274 <label for="radio-choice-1d">Cat</label>
276 <input type="radio" name="radio-choice-1" id="radio-choice-2d" value="choice-2" />
277 <label for="radio-choice-2d">Dog</label>
279 <input type="radio" name="radio-choice-1" id="radio-choice-3d" value="choice-3" />
280 <label for="radio-choice-3d">Hamster</label>
282 <input type="radio" name="radio-choice-1" id="radio-choice-4d" value="choice-4" />
283 <label for="radio-choice-4d">Lizard</label>
287 <div data-role="fieldcontain">
288 <label for="select-choice-d" class="select">Choose shipping method:</label>
289 <select name="select-choice-d" id="select-choice-d">
290 <option value="standard">Standard: 7 day</option>
291 <option value="rush">Rush: 3 days</option>
292 <option value="express">Express: next day</option>
293 <option value="overnight">Overnight</option>
298 </div><!-- /body-d -->
301 <h2>Body swatch E</h2>
302 <div class="ui-body ui-body-e">
304 <div data-role="fieldcontain">
305 <label for="name-e">Text Input:</label>
306 <input type="text" name="name" id="name-e" value="" />
309 <div data-role="fieldcontain">
310 <label for="switch-e">Flip switch:</label>
311 <select name="switch-e" id="switch-e" data-role="slider">
312 <option value="off">Off</option>
313 <option value="on">On</option>
317 <div data-role="fieldcontain">
318 <label for="slider-e">Slider:</label>
319 <input type="range" name="slider" id="slider-e" value="0" min="0" max="100" />
323 <div data-role="fieldcontain">
324 <fieldset data-role="controlgroup" data-type="horizontal">
325 <legend>Font styling:</legend>
326 <input type="checkbox" name="checkbox-6e" id="checkbox-6e" class="custom" />
327 <label for="checkbox-6e">b</label>
329 <input type="checkbox" name="checkbox-7e" id="checkbox-7e" class="custom" />
330 <label for="checkbox-7e"><em>i</em></label>
332 <input type="checkbox" name="checkbox-8e" id="checkbox-8e" class="custom" />
333 <label for="checkbox-8e">u</label>
337 <div data-role="fieldcontain">
338 <fieldset data-role="controlgroup">
339 <legend>Choose a pet:</legend>
340 <input type="radio" name="radio-choice-1" id="radio-choice-1e" value="choice-1" />
341 <label for="radio-choice-1e">Cat</label>
343 <input type="radio" name="radio-choice-1" id="radio-choice-2e" value="choice-2" />
344 <label for="radio-choice-2e">Dog</label>
346 <input type="radio" name="radio-choice-1" id="radio-choice-3e" value="choice-3" />
347 <label for="radio-choice-3e">Hamster</label>
349 <input type="radio" name="radio-choice-1" id="radio-choice-4e" value="choice-4" />
350 <label for="radio-choice-4e">Lizard</label>
354 <div data-role="fieldcontain">
355 <label for="select-choice-e" class="select">Choose shipping method:</label>
356 <select name="select-choice-e" id="select-choice-e">
357 <option value="standard">Standard: 7 day</option>
358 <option value="rush">Rush: 3 days</option>
359 <option value="express">Express: next day</option>
360 <option value="overnight">Overnight</option>
365 </div><!-- /body-e -->
369 </div><!--/content-primary -->
371 <div class="content-secondary">
373 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
375 <h3>More in this section</h3>
377 <ul data-role="listview" data-theme="c" data-dividertheme="d">
379 <li data-role="list-divider">Form elements</li>
380 <li><a href="docs-forms.html">Form basics</a></li>
381 <li><a href="forms-all.html">Form element gallery</a></li>
382 <li><a href="forms-all-mini.html">Mini form element gallery</a></li>
383 <li><a href="textinputs/">Text inputs</a></li>
384 <li><a href="search/">Search inputs</a></li>
385 <li><a href="slider/">Slider</a></li>
386 <li><a href="switch/">Flip toggle switch</a></li>
387 <li><a href="radiobuttons/">Radio buttons</a></li>
388 <li><a href="checkboxes/">Checkboxes</a></li>
389 <li><a href="selects/">Select menus</a></li>
390 <li data-theme="a"><a href="forms-themes.html">Theming forms</a></li>
391 <li><a href="forms-all-native.html">Native form elements</a></li>
392 <li><a href="forms-sample.html">Submitting forms</a></li>
399 </div><!-- /content -->
401 <div data-role="footer" class="footer-docs" data-theme="c">
402 <p>© 2011-12 The jQuery Foundation</p>