Back to Shark UI

Field

docs/components/field

latest10.1 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Field

Copy Markdown

Container for inputs, labels, and helper text.

DocsAPI

PreviewCode

Username

Choose a unique username for your account.

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/field

Anatomy#

FieldSet
├── FieldLegend
└── FieldGroup
    ├── Field
    ├── FieldLabel
    │ └── FieldRequiredIndicator
    ├── FieldTitle
    ├── FieldDescription
    ├── FieldSeparator
    ├── FieldHelper
    └── FieldError

Usage#

import { 
  Field, 
  FieldLabel, 
  FieldInput, 
  FieldHelper, 
  FieldError 
} from "@/components/ui/field";
<Field>
  <FieldLabel>Email</FieldLabel>
  <FieldInput />
  <FieldHelper>Enter your email address</FieldHelper>
  <FieldError>Email is required</FieldError>
</Field>

Examples#

Input#

PreviewCode

Subscribe

Autocomplete#

PreviewCode

Fruits

Select an item.

Combobox#

PreviewCode

Fruits

Select an item.

Combobox Multiple#

PreviewCode

Fruits

Select multiple items.

Textarea#

PreviewCode

Bio

Write a short bio. Maximum 500 characters.

Select#

PreviewCode

Country

Select a country

BrazilMexicoIreland

Used for shipping estimates

Checkbox#

PreviewCode

Receive notifications

You'll receive a notification when someone posts a comment

Checkbox Group#

PreviewCode

Select the items you want to show:

Hard disks

External disks

CDs, DVDs, and iPods

Connected servers

Radio Group#

PreviewCode

Choose Plan

Free

Pro

Enterprise

Select the plan that fits your needs.

Switch#

PreviewCode

Airplane mode

Slider#

Use SliderLabel inside the Slider to label the slider.

PreviewCode

Volume

Adjust the volume of the media player

Number Input#

PreviewCode

Quantity

Field Group#

PreviewCode

Newsletter

Choose how you want to receive updates about new features and product releases.

Weekly digest

Updates

Get notified about important account activity. View activity log

Security alerts

Billing reminders

API Reference#

Field#

Root layout for label, control, and helper/error text.

PropTypeDefault
orientation`"vertical""horizontal"
reversebooleanfalse
invalidboolean-
disabledboolean-
requiredboolean-
readOnlyboolean-
asChildboolean-
classNamestring-

FieldSet#

Groups related form controls semantically.

PropTypeDefault
classNamestring-

FieldLegend#

Legend or label for a FieldSet group.

PropTypeDefault
variant`"legend""label"`
classNamestring-

FieldGroup#

Groups multiple fields with consistent spacing.

PropTypeDefault
classNamestring-

FieldContent#

Wraps label, description, and error. Use with horizontal orientation.

PropTypeDefault
classNamestring-

FieldLabel#

Label associated with the control.

PropTypeDefault
asChildboolean-
classNamestring-

FieldRequiredIndicator#

PropTypeDefault
childrenReactNode"*"
classNamestring-
asChildboolean-

FieldTitle#

Title wrapper for grouped field content.

PropTypeDefault
classNamestring-

FieldDescription#

Helper text or description. Shown in muted foreground.

PropTypeDefault
classNamestring-

FieldSeparator#

Horizontal divider between field groups. Optional center label.

PropTypeDefault
childrenReactNode-
classNamestring-

FieldHelper#

Alias for FieldDescription. Use for consistency with other form libraries.

PropTypeDefault
classNamestring-

FieldError#

Error message shown when the field is invalid. Shown in destructive color.

PropTypeDefault
classNamestring-

For a complete list of props, see the Ark UI documentation.

[

Previous page

Editable ](/docs/components/editable)[

Next page

File Upload ](/docs/components/file-upload)

On This Page

InstallationAnatomyUsageExamplesInputAutocompleteComboboxCombobox MultipleTextareaSelectCheckboxCheckbox GroupRadio GroupSwitchSliderNumber InputField GroupAPI ReferenceFieldFieldSetFieldLegendFieldGroupFieldContentFieldLabelFieldRequiredIndicatorFieldTitleFieldDescriptionFieldSeparatorFieldHelperFieldError