Field
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Field component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Add your field HTML
Use class="field" for one control and class="fieldset" for related controls. Use a native <fieldset> when the group needs a <legend>; otherwise use a labelled role="group".
HTML structure
<fieldset class="fieldset">- Native group for related fields. Use
<legend>for the label and a following<p>for description. <div role="group" class="fieldset">- Structural group when
<fieldset>is not appropriate. Addaria-labeloraria-labelledby. <div role="group" class="field">- Single field wrapper. Add
data-orientationwhen needed. <label>- Label for the control. Use
forwhen the control has anid. <input>,<select>,<textarea>- Native form control. Put
aria-invalid="true"on the invalid control, not only on the wrapper. <section>- Optional content wrapper for label and description when the control sits beside text.
<p>- Helper text or error text. Use
role="alert"for validation errors and connect it witharia-describedby.
Examples
Input
Textarea
Select
Select your department or area of work.
Slider
Set your maximum budget (up to $800).
Fieldset
Checkbox
Your Desktop & Documents folders are being synced with iCloud Drive. You can access them from other devices.
Radio
Switch
Enable multi-factor authentication. If you do not have a two-factor device, you can use a one-time code sent to your email.
Choice card
Wrap a .field inside a <label> to create selectable field cards. This works with radio, checkbox, and switch controls.
Field group
Stack fields inside a group and use .field-separator to divide sections.
Responsive layout
Use data-orientation="responsive" to stack by default and switch to horizontal in wider containers.
Validation and errors
Add data-invalid to .field and aria-invalid="true" to the invalid control.
Enter a valid email address.
RTL
Add dir="rtl" to the field, fieldset, or an ancestor.