Fieldset
Semantic HTML fieldset component for grouping related form fields with optional legend label
Basic Usage
The most basic fieldset with a label grouping related fields:
<neura::fieldset label="Personal Information">
<neura::field>
<neura::label>First Name</neura::label>
<neura::input type="text" placeholder="John" />
</neura::field>
<neura::field>
<neura::label>Last Name</neura::label>
<neura::input type="text" placeholder="Doe" />
</neura::field>
</neura::fieldset>
Without Label
You can use a fieldset without a label for visual grouping only:
<neura::fieldset>
<neura::field>
<neura::label>Email</neura::label>
<neura::input type="email" placeholder="email@example.com" />
</neura::field>
<neura::field>
<neura::label>Password</neura::label>
<neura::input type="password" placeholder="Enter password" />
</neura::field>
</neura::fieldset>
Hidden Label
Use labelHidden to hide the label visually while keeping it accessible to screen readers:
<neura::fieldset label="Account Details" labelHidden>
...
</neura::fieldset>
Multiple Fieldsets
Group different sections of a form using multiple fieldsets:
Use Cases
Registration Form
Settings Form
Best Practices
Do
- Use fieldsets to group logically related form fields
- Provide descriptive labels for fieldsets
- Use fieldsets for accessibility and semantic HTML structure
- Keep fieldsets focused on a single topic or section
Don't
- Don't use fieldsets for single fields (use field component instead)
- Don't nest fieldsets unnecessarily
- Don't use fieldsets purely for visual grouping without semantic meaning
- Don't use very long or verbose fieldset labels
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| label | string|null | null | Legend label text for the fieldset. Displayed as a legend element. |
| labelHidden | boolean | false | Hides the label visually while keeping it accessible to screen readers (sr-only class). |
| class | string | - | Additional CSS classes. Default: rounded-box border border-black/10 p-5 dark:border-white/10 text-start |