Components / Core
FieldSet
Groups related controls under one label (MUI's FormControl + FormLabel + FormGroup).
import { FieldSet } from "@stylhero/ui";
Example
Code
import { FieldSet, Switch } from "@stylhero/ui";
function FieldSetExample() {
return (
<FieldSet legend="Notifications" hint="Choose how we contact you.">
<Switch label="Email" defaultChecked />
<Switch label="Text message" />
</FieldSet>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required |
ReactNode |
- | |
legend required |
ReactNode |
- | The group's question, e.g. "Notify me by". |
error |
ReactNode |
- | |
hint |
ReactNode |
- | |
row |
boolean |
- | Lay the options out side by side. |
Also takes every <fieldset> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Accessibility
- A native
<fieldset>with a<legend>: screen readers announce the legend when focus enters the group.
Generated from src/components/FieldSet.tsx. Something wrong or missing? Open an issue.