Fieldset
A <fieldset> that groups related controls under an optional <legend>, with a single disabled toggle that natively cascades to every control inside.
Preview
<x-ui.fieldset legend="Notifications" class="mx-auto w-full max-w-md">
<x-ui.field name="notify_email" label="Email">
<x-ui.input name="notify_email" type="email" placeholder="you@example.com" />
</x-ui.field>
<label class="flex items-center gap-2 text-sm text-foreground">
<x-ui.checkbox name="weekly_digest" />
{{ __('Send me the weekly digest') }}
</label>
</x-ui.fieldset>
Installation
php artisan ui:add fieldset
Registry contract
php artisan ui:add fieldset
writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.
-
resources/views/components/ui/fieldset/fieldset.blade.php
- Registry dependencies
- None — installs on its own.
- Packages
-
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.
# Brok UI: Fieldset (`fieldset`)
A <fieldset> that groups related controls under an optional <legend>, with a single disabled toggle that natively cascades to every control inside.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add fieldset
```
## Usage
```blade
<x-ui.fieldset legend="Notifications" class="mx-auto w-full max-w-md">
<x-ui.field name="notify_email" label="Email">
<x-ui.input name="notify_email" type="email" placeholder="[email protected]" />
</x-ui.field>
<label class="flex items-center gap-2 text-sm text-foreground">
<x-ui.checkbox name="weekly_digest" />
{{ __('Send me the weekly digest') }}
</label>
</x-ui.fieldset>
```
## Props
- `legend` (mixed|null, default `null`) — Legend text. For richer legend markup, fill the legend slot instead.
- `disabled` (bool, default `false`) — Disables the whole group; cascades natively to every contained control.
## Use when
- Use to collect, group, and clearly label related input so users understand what is being asked and can recover from errors.
- Grouping a set of related fields (such as an address, or a radio/checkbox set) under one heading.
- Needing to disable every control inside a section at once, natively, without wiring each control individually.
## Avoid when
- Do not create dense unlabeled forms; start from one thing per page or one conceptual question per step when the task is unfamiliar or high stakes.
- Labelling a single field; use label instead.
- A purely visual grouping with no shared legend or disable behaviour; use a plain div instead.
## Anti-patterns
- Dense unlabeled forms
- Collecting information without a task need
## Rules
- Use the `<brok:fieldset>` tag (or `<x-ui.fieldset>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.
## Links
- Docs: https://brokui.dev/docs/components/fieldset
- Registry JSON (files, props, contract): https://brokui.dev/r/open/fieldset.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| legend | mixed | null | null | Legend text. For richer legend markup, fill the legend slot instead. |
| disabled | bool | false | Disables the whole group; cascades natively to every contained control. |
Slots
default— The grouped controls.x-ui.fieldset.fieldset— Installed subcomponent from the registry item.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Renders a native <fieldset>, so disabled cascades to every control inside without extra wiring.
- The legend slot wins over the legend prop when both are supplied, for custom legend markup.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Collect and organize related user input.
Use when
- Use to collect, group, and clearly label related input so users understand what is being asked and can recover from errors.
- Grouping a set of related fields (such as an address, or a radio/checkbox set) under one heading.
- Needing to disable every control inside a section at once, natively, without wiring each control individually.
Avoid when
- Do not create dense unlabeled forms; start from one thing per page or one conceptual question per step when the task is unfamiliar or high stakes.
- Labelling a single field; use label instead.
- A purely visual grouping with no shared legend or disable behaviour; use a plain div instead.
Use instead
- Focused question pages
- A smaller set of directly labeled fields
Anti-patterns
- Dense unlabeled forms
- Collecting information without a task need
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- No component-owned keyboard interaction; native element behavior applies.
- Focus
none
- The legend is read by screen readers as the group's accessible name before each control inside it.
- Native fieldset/legend semantics work without any ARIA role or extra attribute.
- Semantic HTML and a stable
data-slotattribute for styling and scripting hooks. - Focus-visible rings use the
ringtoken, so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
- Labels go through
__()and layout uses logical properties (ms-*,text-start), so it mirrors underdir="rtl"— flip the preview to RTL to confirm. - Dark mode uses the same semantic tokens under the
darkclass; high contrast follows forced-color system tokens.
Livewire
Livewire can update this component through forwarded wire:* attributes.
Source
The exact, editable file ui:add writes
into your app. Previews render this same code; there are no preview-only components.
@props([
// Optional legend text. For richer legend markup, fill the `legend` slot instead.
'legend' => null,
// Disable the whole group (cascades to every contained control natively).
'disabled' => false,
])
<fieldset
data-slot="fieldset"
@disabled($disabled)
{{ $attributes->merge(['class' => 'min-w-0 space-y-4 border-0 p-0']) }}
>
@isset($legend)
{{-- Slot wins over the prop for custom legend markup. --}}
<legend data-slot="fieldset-legend" class="text-base font-semibold leading-none text-foreground">
{{ $legend }}
</legend>
@elseif (filled($legend))
<legend data-slot="fieldset-legend" class="text-base font-semibold leading-none text-foreground">
{{ __($legend) }}
</legend>
@endisset
{{ $slot }}
</fieldset>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.3 - Status
- Stable
- License
-
open - Accessibility reviewed
- No review date recorded
- Last breaking change
- No date recorded
- Deprecation
- Not deprecated
- Contract
-
v6 - Foundation
-
≥ 1.0.0