@@ -130,49 +130,9 @@ instead.
130
130
131
131
## Checkbox
132
132
133
- Create a custom checkbox by adding a ` span ` with the ` form-checkbox ` class next to an
134
- ` input[type=checkbox] ` .
135
-
136
- Hide the real checkbox element using the ` sr-only ` class, and hide the span from screen readers
137
- using ` aria-hidden ` .
138
-
139
133
Control the layout of the checkbox and label however you like — the ` form-checkbox ` class doesn't
140
134
impose any opinions in that regard. Here we've used flexbox to center the checkbox with the label.
141
135
142
- <CodeSample code = { `
143
- <div class="block">
144
- <span class="text-gray-700">Checkboxes</span>
145
- <div class="mt-2">
146
- <div>
147
- <label class="inline-flex items-center">
148
- <input type="checkbox" class="sr-only" checked/>
149
- <span class="form-checkbox text-gray-800" aria-hidden="true"></span>
150
- <span class="ml-2">Option 1</span>
151
- </label>
152
- </div>
153
- <div>
154
- <label class="inline-flex items-center">
155
- <input type="checkbox" class="sr-only"/>
156
- <span class="form-checkbox text-gray-800" aria-hidden="true"></span>
157
- <span class="ml-2">Option 2</span>
158
- </label>
159
- </div>
160
- <div>
161
- <label class="inline-flex items-center">
162
- <input type="checkbox" class="sr-only"/>
163
- <span class="form-checkbox text-gray-800" aria-hidden="true"></span>
164
- <span class="ml-2">Option 3</span>
165
- </label>
166
- </div>
167
- </div>
168
- </div>
169
- ` } />
170
-
171
- ### Styling checkboxes directly (No IE 11 support)
172
-
173
- If you only need to support Edge and not IE 11, you can also add the ` form-checkbox ` class to
174
- ` input[type=checkbox] ` elements directly and avoid the extra presentational ` span ` element.
175
-
176
136
<CodeSample code = { `
177
137
<div class="block">
178
138
<span class="text-gray-700">Checkboxes</span>
@@ -210,22 +170,19 @@ color utilities, like `text-indigo-600`.
210
170
<div class="mt-2">
211
171
<div>
212
172
<label class="inline-flex items-center">
213
- <input type="checkbox" class="sr-only" checked/>
214
- <span class="form-checkbox text-indigo-600" aria-hidden="true"></span>
173
+ <input type="checkbox" class="form-checkbox text-indigo-600" checked/>
215
174
<span class="ml-2">Option 1</span>
216
175
</label>
217
176
</div>
218
177
<div>
219
178
<label class="inline-flex items-center">
220
- <input type="checkbox" class="sr-only" checked/>
221
- <span class="form-checkbox text-blue-500" aria-hidden="true"></span>
179
+ <input type="checkbox" class="form-checkbox text-blue-500" checked/>
222
180
<span class="ml-2">Option 2</span>
223
181
</label>
224
182
</div>
225
183
<div>
226
184
<label class="inline-flex items-center">
227
- <input type="checkbox" class="sr-only" checked/>
228
- <span class="form-checkbox text-pink-600" aria-hidden="true"></span>
185
+ <input type="checkbox" class="form-checkbox text-pink-600" checked/>
229
186
<span class="ml-2">Option 3</span>
230
187
</label>
231
188
</div>
@@ -244,22 +201,19 @@ use Tailwind's width and height utilities, like `h-6` and `w-6`.
244
201
<div class="mt-2">
245
202
<div>
246
203
<label class="inline-flex items-center">
247
- <input type="checkbox" class="sr-only" checked/>
248
- <span class="form-checkbox h-4 w-4 text-gray-800" aria-hidden="true"></span>
204
+ <input type="checkbox" class="form-checkbox h-4 w-4 text-gray-800" checked/>
249
205
<span class="ml-2">Option 1</span>
250
206
</label>
251
207
</div>
252
208
<div class="mt-1">
253
209
<label class="inline-flex items-center">
254
- <input type="checkbox" class="sr-only"/>
255
- <span class="form-checkbox h-6 w-6 text-gray-800" aria-hidden="true"></span>
210
+ <input type="checkbox" class="form-checkbox h-6 w-6 text-gray-800"/>
256
211
<span class="ml-3 text-lg">Option 2</span>
257
212
</label>
258
213
</div>
259
214
<div class="mt-1">
260
215
<label class="inline-flex items-center">
261
- <input type="checkbox" class="sr-only"/>
262
- <span class="form-checkbox h-8 w-8 text-gray-800" aria-hidden="true"></span>
216
+ <input type="checkbox" class="form-checkbox h-8 w-8 text-gray-800"/>
263
217
<span class="ml-4 text-xl">Option 3</span>
264
218
</label>
265
219
</div>
@@ -271,12 +225,6 @@ use Tailwind's width and height utilities, like `h-6` and `w-6`.
271
225
272
226
## Radio Button
273
227
274
- Create a custom radio button by adding a ` span ` with the ` form-radio ` class next to an
275
- ` input[type=radio] ` .
276
-
277
- Hide the real radio button using the ` sr-only ` class, and hide the span from screen readers
278
- using ` aria-hidden ` .
279
-
280
228
Control the layout of the radio button and label however you like — the ` form-radio ` class doesn't
281
229
impose any opinions in that regard. Here we've used flexbox to center the radio button with the label.
282
230
@@ -286,59 +234,26 @@ impose any opinions in that regard. Here we've used flexbox to center the radio
286
234
<div class="mt-2">
287
235
<div>
288
236
<label class="inline-flex items-center">
289
- <input type="radio" class="sr-only" name="radio" value="1" checked/>
290
- <span class="form-radio text-gray-800" aria-hidden="true"></span>
237
+ <input type="radio" class="form-radio text-gray-800" name="radio" value="1" checked/>
291
238
<span class="ml-2">Option 1</span>
292
239
</label>
293
240
</div>
294
241
<div>
295
242
<label class="inline-flex items-center">
296
- <input type="radio" class="sr-only" name="radio" value="2"/>
297
- <span class="form-radio text-gray-800" aria-hidden="true"></span>
243
+ <input type="radio" class="form-radio text-gray-800" name="radio" value="2"/>
298
244
<span class="ml-2">Option 2</span>
299
245
</label>
300
246
</div>
301
247
<div>
302
248
<label class="inline-flex items-center">
303
- <input type="radio" class="sr-only" name="radio" value="3"/>
304
- <span class="form-radio text-gray-800" aria-hidden="true"></span>
249
+ <input type="radio" class="form-radio text-gray-800" name="radio" value="3"/>
305
250
<span class="ml-2">Option 3</span>
306
251
</label>
307
252
</div>
308
253
</div>
309
254
</div>
310
255
` } />
311
256
312
- ### Styling radio buttons directly (No IE 11 support)
313
-
314
- If you only need to support Edge and not IE 11, you can also add the ` form-checkbox ` class to
315
- ` input[type=checkbox] ` elements directly and avoid the extra presentational ` span ` element.
316
-
317
- <CodeSample code = { `
318
- <div class="block">
319
- <span class="text-gray-700">Radio Buttons</span>
320
- <div class="mt-2">
321
- <div>
322
- <label class="inline-flex items-center">
323
- <input type="radio" class="form-radio text-gray-800" name="radio-direct" value="1" checked/>
324
- <span class="ml-2">Option 1</span>
325
- </label>
326
- </div>
327
- <div>
328
- <label class="inline-flex items-center">
329
- <input type="radio" class="form-radio text-gray-800" name="radio-direct" value="2"/>
330
- <span class="ml-2">Option 2</span>
331
- </label>
332
- </div>
333
- <div>
334
- <label class="inline-flex items-center">
335
- <input type="radio" class="form-radio text-gray-800" name="radio-direct" value="3"/>
336
- <span class="ml-2">Option 3</span>
337
- </label>
338
- </div>
339
- </div>
340
- </div>
341
- ` } />
342
257
343
258
### Changing the color
344
259
@@ -351,22 +266,19 @@ color utilities, like `text-indigo-600`.
351
266
<div class="mt-2">
352
267
<div>
353
268
<label class="inline-flex items-center">
354
- <input type="radio" class="sr-only" name="radio-colors" value="1" checked/>
355
- <span class="form-radio text-indigo-600" aria-hidden="true"></span>
269
+ <input type="radio" class="form-radio text-indigo-600" name="radio-colors" value="1" checked/>
356
270
<span class="ml-2">Option 1</span>
357
271
</label>
358
272
</div>
359
273
<div>
360
274
<label class="inline-flex items-center">
361
- <input type="radio" class="sr-only" name="radio-colors" value="2"/>
362
- <span class="form-radio text-blue-500" aria-hidden="true"></span>
275
+ <input type="radio" class="form-radio text-blue-500" name="radio-colors" value="2"/>
363
276
<span class="ml-2">Option 2</span>
364
277
</label>
365
278
</div>
366
279
<div>
367
280
<label class="inline-flex items-center">
368
- <input type="radio" class="sr-only" name="radio-colors" value="3"/>
369
- <span class="form-radio text-pink-600" aria-hidden="true"></span>
281
+ <input type="radio" class="form-radio text-pink-600" name="radio-colors" value="3"/>
370
282
<span class="ml-2">Option 3</span>
371
283
</label>
372
284
</div>
@@ -385,22 +297,19 @@ use Tailwind's width and height utilities, like `h-6` and `w-6`.
385
297
<div class="mt-2">
386
298
<div>
387
299
<label class="inline-flex items-center">
388
- <input type="radio" class="sr-only" name="radio-sizes" value="1" checked/>
389
- <span class="form-radio h-4 w-4 text-gray-800" aria-hidden="true"></span>
300
+ <input type="radio" class="form-radio h-4 w-4 text-gray-800" name="radio-sizes" value="1" checked/>
390
301
<span class="ml-2">Option 1</span>
391
302
</label>
392
303
</div>
393
304
<div class="mt-1">
394
305
<label class="inline-flex items-center">
395
- <input type="radio" class="sr-only" name="radio-sizes" value="2"/>
396
- <span class="form-radio h-6 w-6 text-gray-800" aria-hidden="true"></span>
306
+ <input type="radio" class="form-radio h-6 w-6 text-gray-800" name="radio-sizes" value="2"/>
397
307
<span class="ml-3 text-lg">Option 2</span>
398
308
</label>
399
309
</div>
400
310
<div class="mt-1">
401
311
<label class="inline-flex items-center">
402
- <input type="radio" class="sr-only" name="radio-sizes" value="3"/>
403
- <span class="form-radio h-8 w-8 text-gray-800" aria-hidden="true"></span>
312
+ <input type="radio" class="form-radio h-8 w-8 text-gray-800" name="radio-sizes" value="3"/>
404
313
<span class="ml-4 text-xl">Option 3</span>
405
314
</label>
406
315
</div>
0 commit comments