Fieldset
A native fieldset element with an easily stylable legend.
import { Field } from 'base-ui-solid/field';
import { Fieldset } from 'base-ui-solid/fieldset';
import styles from './index.module.css';
export default function ExampleField() {
return (
<Fieldset.Root class={styles.Fieldset}>
<Fieldset.Legend class={styles.Legend}>Billing details</Fieldset.Legend>
<Field.Root class={styles.Field}>
<Field.Label class={styles.Label}>Company</Field.Label>
<Field.Control placeholder="Enter company name" class={styles.Input} />
</Field.Root>
<Field.Root class={styles.Field}>
<Field.Label class={styles.Label}>Tax ID</Field.Label>
<Field.Control placeholder="Enter fiscal number" class={styles.Input} />
</Field.Root>
</Fieldset.Root>
);
}
Anatomy
Import the component and assemble its parts:
Anatomy
import { Fieldset } from 'base-ui-solid/fieldset';
<Fieldset.Root>
<Fieldset.Legend />
</Fieldset.Root>;
API reference
Root
Groups a shared legend with related controls.
Renders a <fieldset> element.
Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Root.State
type FieldsetRootState = {
/** Whether the component should ignore user interaction. */
disabled: boolean;
};Legend
An accessible label that is automatically associated with the fieldset.
Renders a <div> element.
Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Legend.State
type FieldsetLegendState = {
/** Whether the component should ignore user interaction. */
disabled: boolean;
};