Components

Fieldset

A native fieldset element with an easily stylable legend.

Billing details

Anatomy#

Import the component and assemble its parts:

Anatomytsx
import { Fieldset } from '@egoist/solid-base/fieldset';

<Fieldset.Root>
  <Fieldset.Legend />
</Fieldset.Root>;

Examples#

Labeling a group of controls#

<Fieldset.Legend> labels the whole fieldset, which makes it a good fit for groups such as a Checkbox Group or a Radio Group. Render the group as the fieldset itself with a render callback so the legend names it, and wrap it in a <Field.Root> to give it a form name:

Storage type

Disabling a group#

Set disabled on <Fieldset.Root> to disable every field inside it.

API reference#

<Fieldset.Root>

Groups a shared legend with related controls. Renders a <fieldset> element.

PropTypeDefault
disabledbooleanfalse

Whether the component should ignore user interaction.

classstring | ClassValue | ((state: State) => ClassValue)—

CSS class applied to the element, or a function that returns a class based on the component's state.

styleJSX.CSSProperties | string | ((state: State) => JSX.CSSProperties | string)—

Style applied to the element, or a function that returns a style based on the component's state.

renderkeyof JSX.IntrinsicElements | ((props: HTMLProps, state: State) => JSX.Element)—

Allows you to replace the component's HTML element with a different tag, or compose it with another component.

Accepts a tag name, or a function that receives the props to spread and the component's state, and returns the element to render.

<Fieldset.Legend>

An accessible label that is automatically associated with the fieldset. Renders a <div> element.

PropTypeDefault
idstring—

The id of the element. A generated id is used by default.

classstring | ClassValue | ((state: State) => ClassValue)—

CSS class applied to the element, or a function that returns a class based on the component's state.

styleJSX.CSSProperties | string | ((state: State) => JSX.CSSProperties | string)—

Style applied to the element, or a function that returns a style based on the component's state.

renderkeyof JSX.IntrinsicElements | ((props: HTMLProps, state: State) => JSX.Element)—

Allows you to replace the component's HTML element with a different tag, or compose it with another component.

Accepts a tag name, or a function that receives the props to spread and the component's state, and returns the element to render.

Data attributeDescription
data-disabled

Present when the fieldset is disabled.