Fieldset

Groups related form fields under one legend, such as the parts of an address.

Contact detailsTell us how to reach you about your order.

Usage

Code
import { Fieldset } from '@leverui/components';
Code
<Fieldset.Root>
  <Fieldset.Legend />
  <Fieldset.Content />
</Fieldset.Root>

Examples

Disabled

Use the disabled prop to disable the fieldset to disable all input elements within the fieldset.

Shipping details

Invalid

Use the invalid prop to mark the fieldset as invalid. This will show the error text.

Note: You need to pass the invalid prop to the Field component within the fieldset to make each input element invalid.

Shipping details
Some fields are invalid. Please check them.

Guides

Renders a native fieldset with a legend that names the group. Helper text joins the group's accessible description. Put controls in Fieldset.Content, a styled div.

disabled on Fieldset.Root disables every form control inside. This is native fieldset behavior, so keep the default tag if you rely on it. invalid shows Fieldset.ErrorText and adds its id to the group's accessible description.

Own the state: create it with useFieldset and pass it to Fieldset.RootProvider. Read the nearest fieldset's state with Fieldset.Context or useFieldsetContext. The state is reactive.

Props

PropDefaultTypeDescription
size'md''sm' | 'md' | 'lg'Fieldset size.
asfieldsetNative tag nameHTML tag to render.
asChild—Solid render functionRender your own element with the fieldset's props.
unstyled—booleanTurn off the Lever UI styles.
disabled—booleanDisable the fieldset.
invalid—booleanMark the fieldset invalid.

Customize with CSS

Load the package stylesheet first. Classes: .leverui-fieldset__root, __legend, __content, __helperText, __errorText. Root variables: --leverui-fieldset-space-y, --leverui-fieldset-content-gap, --leverui-fieldset-legend-size.

Code
.account-form {
  --leverui-colors-fg-error: #a02fd0;
  --leverui-fieldset-content-gap: 1.5rem;
}

For a one-off change, use class and style. unstyled turns off the default styles. The root and the parts pass native HTML attributes and callback refs to their elements.

Explorer

Click a part name to highlight it in the preview.

Component Anatomy

Hover to highlight, click to select parts