- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
Installation#
pnpm dlx shadcn@latest add @force-ui-svelte/field
Usage#
<script lang="ts">
import * as Field from "$lib/components/ui/field/index.js";
</script><Field.Set>
<Field.Legend>Profile</Field.Legend>
<Field.Description>This appears on invoices and emails.</Field.Description>
<Field.Group>
<Field.Field>
<Field.Label for="name">Full name</Field.Label>
<Input id="name" autocomplete="off" placeholder="Evil Rabbit" />
<Field.Description
>This appears on invoices and emails.</Field.Description
>
</Field.Field>
<Field.Field>
<Field.Label for="username">Username</Field.Label>
<Input id="username" autoComplete="off" aria-invalid />
<Field.Error>Choose another username.</Field.Error>
</Field.Field>
<Field.Field orientation="horizontal">
<Switch id="newsletter" />
<Field.Label for="newsletter">Subscribe to the newsletter</Field.Label>
</Field.Field>
</Field.Group>
</Field.Set>Composition#
Field.Field#
A single control with label, helper text, and validation.
Field.Field
├── Field.Label
├── Input / Textarea / Switch / Select
├── Field.Description
└── Field.ErrorField.Group#
Related fields in one group. Use Field.Separator between sections when needed.
Field.Group
├── Field.Field
│ ├── Field.Label
│ ├── Input / Textarea / Switch / Select
│ ├── Field.Description
│ └── Field.Error
├── Field.Separator
└── Field.Field
├── Field.Label
└── Input / Textarea / Switch / SelectField.Set#
Semantic grouping with a legend and description, usually containing a Field.Group.
Field.Set
├── Field.Legend
├── Field.Description
└── Field.Group
├── Field.Field
│ ├── Field.Label
│ ├── Input / Textarea / Switch / Select
│ ├── Field.Description
│ └── Field.Error
└── Field.Field
├── Field.Label
└── Input / Textarea / Switch / SelectAnatomy#
The Field family is designed for composing accessible forms. A typical field is structured as follows:
<Field.Field>
<Field.Label for="input-id">Label</Field.Label>
<Field.Description>Optional helper text.</Field.Description>
<Field.Error>Validation message.</Field.Error>
</Field.Field>Field.Fieldis the core wrapper for a single field.Field.Contentis a flex column that groups label and description. Not required if you have no description.- Wrap related fields with
Field.Group, and useField.SetwithField.Legendfor semantic grouping.
Form#
See the Form documentation for building forms with the Field component and React Hook Form, Tanstack Form, or Formisch.
Examples#
Input#
Textarea#
Select#
Slider#
Fieldset#
Checkbox#
Radio#
Switch#
Choice Card#
Wrap Field components inside Field.Label to create selectable field groups. This works with RadioItem, Checkbox and Switch components.
Field Group#
Stack Field.Field components with Field.Group. Add Field.Separator to divide them.
RTL#
To enable RTL support in Force UI, see the RTL configuration guide.
Responsive Layout#
- Vertical fields: Default orientation stacks label, control, and helper text—ideal for mobile-first layouts.
- Horizontal fields: Set
orientation="horizontal"onField.Fieldto align the label and control side-by-side. Pair withField.Contentto keep descriptions aligned. - Responsive fields: Set
orientation="responsive"for automatic column layouts inside container-aware parents. Apply@container/field-groupclasses onField.Groupto switch orientations at specific breakpoints.
Validation and Errors#
- Add
data-invalidtoField.Fieldto switch the entire block into an error state. - Add
aria-invalidon the input itself for assistive technologies. - Render
Field.Errorimmediately after the control or insideField.Contentto keep error messages aligned with the field.
<Field.Field data-invalid>
<Field.Label for="email">Email</Field.Label>
<Input id="email" type="email" aria-invalid />
<Field.Error>Enter a valid email address.</Field.Error>
</Field.Field>Accessibility#
Field.SetandField.Legendkeep related controls grouped for keyboard and assistive tech users.Field.Fieldoutputsrole="group"so nested controls inherit labeling fromField.LabelandField.Legendwhen combined.- Apply
Field.Separatorsparingly to ensure screen readers encounter clear section boundaries.
API Reference#
Field.Set#
Container that renders a semantic fieldset with spacing presets.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Set>
<Field.Legend>Delivery</Field.Legend>
<Field.Group>{/* Fields */}</Field.Group>
</Field.Set>Field.Legend#
Legend element for a Field.Set. Switch to the label variant to align with label sizing.
| Prop | Type | Default |
|---|---|---|
variant | "legend" | "label" | "legend" |
class | string |
<Field.Legend variant="label">Notification Preferences</Field.Legend>The Field.Legend has two variants: legend and label. The label variant applies label sizing and alignment. Handy if you have nested Field.Set.
Field.Group#
Layout wrapper that stacks Field.Field components and enables container queries for responsive orientations.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Group class="@container/field-group flex flex-col gap-6">
<Field.Field>{/* ... */}</Field.Field>
<Field.Field>{/* ... */}</Field.Field>
</Field.Group>Field.Field#
The core wrapper for a single field. Provides orientation control, invalid state styling, and spacing.
| Prop | Type | Default |
|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | "vertical" |
class | string | |
data-invalid | boolean |
<Field.Field orientation="horizontal">
<Field.Label for="remember">Remember me</Field.Label>
<Switch id="remember" />
</Field.Field>Field.Content#
Flex column that groups control and descriptions when the label sits beside the control. Not required if you have no description.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Field>
<Checkbox id="notifications" />
<Field.Content>
<Field.Label for="notifications">Notifications</Field.Label>
<Field.Description>Email, SMS, and push options.</Field.Description>
</Field.Content>
</Field.Field>Field.Label#
Label styled for both direct inputs and nested Field.Field children.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Label for="email">Email</Field.Label>Field.Title#
Renders a title with label styling inside Field.Content.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Content>
<Field.Title>Enable Touch ID</Field.Title>
<Field.Description>Unlock your device faster.</Field.Description>
</Field.Content>Field.Description#
Helper text slot that automatically balances long lines in horizontal layouts.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Description>We never share your email with anyone.</Field.Description>Field.Separator#
Visual divider to separate sections inside a Field.Group. Accepts optional inline content.
| Prop | Type | Default |
|---|---|---|
class | string |
<Field.Separator>Or continue with</Field.Separator>Field.Error#
Accessible error container that accepts children or an errors array (e.g., from form validation).
| Prop | Type | Default |
|---|---|---|
errors | Array<{ message?: string } | undefined> | |
class | string |
<Field.Error errors={errors.username} />When the errors array contains multiple messages, the component renders a list automatically.
Field.Error also accepts issues produced by any validator that implements Standard Schema, including Zod, Valibot, and ArkType. Pass the issues array from the schema result directly to render a unified error list across libraries.
On This Page
InstallationUsageCompositionField.FieldField.GroupField.SetAnatomyFormExamplesInputTextareaSelectSliderFieldsetCheckboxRadioSwitchChoice CardField GroupRTLResponsive LayoutValidation and ErrorsAccessibilityAPI ReferenceField.SetField.LegendField.GroupField.FieldField.ContentField.LabelField.TitleField.DescriptionField.SeparatorField.Error