Fieldset
Introduction
Section titled “Introduction”Enhances a native <fieldset> that groups related controls, such as an address, a date of birth, or contact preferences, with the AbsoluteUI legend, help text, required marker, and a group-level error. Fieldset.enhance keeps the fieldset’s own controls in place; the native element provides the group semantics and the disabled state.
- Native groupingEnhances a native fieldset, keeping its controls in place and its built-in group semantics.
- Legend and helpA styled legend that can be visually hidden, plus group help text read with the group.
- Group-level errorOne error message for the whole group, for checks no single control can make.
- Disable in one stepThe native disabled state turns off every control inside the group.
Use it for
- Several fields answer one question: address, date of birth, contact preferences.
- A validation rule that spans fields: ‘Enter a street and a city’, ‘Choose at least one channel’.
Use something else for
- One control: use Form Field or the control’s own label.
- A set of checkboxes or radios with one value: use Checkbox Group or Radio Group (they render their own fieldset).
- Visual grouping without a shared question: use Card or layout primitives.
Anatomy
<fieldset class="aui-fieldset [aui-fieldset--invalid]" aria-describedby="help error ..."> <legend class="aui-field__label">Legend<span class="aui-field__required" aria-hidden="true">*</span><span>(required) (visually hidden)</span></legend> <div class="aui-field__description">help</div> <div class="aui-field__error aui-validation-message">icon + group error</div> ... the fieldset's own controls ...</fieldset>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Fieldset in the Employee profile form showcase
Section titled “Fieldset in the Employee profile form showcase”The part of the Employee profile form showcase that uses Fieldset. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Forms showcase: an employee profile form that uses every form control together,// with constraint validation, a cross-field rule, the error summary, reset, and live options.import { Button } from '@absoluteui/components/button';import { Checkbox } from '@absoluteui/components/checkbox';import { CheckboxGroup } from '@absoluteui/components/checkbox-group';import { Combobox } from '@absoluteui/components/combobox';import { Fieldset } from '@absoluteui/components/fieldset';import { Form, type FormSubmitDetail } from '@absoluteui/components/form';import { FormField } from '@absoluteui/components/form-field';import { MultiSelect } from '@absoluteui/components/multi-select';import { NumberInput } from '@absoluteui/components/number-input';import { RadioGroup } from '@absoluteui/components/radio-group';import { Select } from '@absoluteui/components/select';import { Slider } from '@absoluteui/components/slider';import { Switch } from '@absoluteui/components/switch';import { TextInput } from '@absoluteui/components/text-input';import { Textarea } from '@absoluteui/components/textarea';import { ValidationMessage } from '@absoluteui/components/validation-message';import { action, annotate, choice, createShowcase, hostIn, toggle } from './kit.js';
const sc = createShowcase({ title: 'Employee profile', description: 'Every form control in one form: required fields, formats, ranges, a cross-field rule, and an error summary on submit.',});
const form = document.createElement('form');form.className = 'sc-form';form.noValidate = true;sc.stage.append(form);
// Each fieldset declares its controls, so a component's focus view shows its own group.const fieldset = (legend: string, description?: string): HTMLFieldSetElement => { const fs = document.createElement('fieldset'); form.append(fs); Fieldset.enhance(fs, { legend, ...(description ? { description } : {}) }); return fs;};
const DEPARTMENTS = [ { value: 'eng', label: 'Engineering' }, { value: 'fin', label: 'Finance' }, { value: 'hr', label: 'People' }, { value: 'ops', label: 'Operations' }, { value: 'sales', label: 'Sales' },];const MANAGERS = ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu', 'Hiro Tanaka'].map((name) => ({ value: name.toLowerCase().replace(/\s+/g, '-'), label: name }));const SKILLS = ['Accessibility', 'Angular', 'Data analysis', 'Design systems', 'Finance', 'Negotiation', 'People management', 'TypeScript'].map((s) => ({ value: s.toLowerCase().replace(/\s+/g, '-'), label: s }));
// Personal details.const personal = annotate(fieldset('Personal details'), ['form', 'error-summary', 'fieldset', 'text-input', 'textarea', 'form-field']);const name = TextInput.create(hostIn(personal), { label: 'Full name', name: 'name', required: true, minLength: 2, autocomplete: 'name' });const email = TextInput.create(hostIn(personal), { label: 'Work email', name: 'email', type: 'email', required: true, autocomplete: 'email', description: 'Used for sign-in and notifications.' });const phone = TextInput.create(hostIn(personal), { label: 'Phone', name: 'phone', type: 'tel', inputMode: 'tel', pattern: '[+]?[0-9 ]{7,20}', description: 'Digits and spaces, with an optional leading +.' });const bio = Textarea.create(hostIn(personal), { label: 'About', name: 'bio', maxLength: 280, showCounter: true, rows: 3, resize: 'vertical' });
// A native control labelled and validated by Form Field.const badge = document.createElement('input');badge.name = 'badge';badge.inputMode = 'numeric';badge.pattern = '[0-9]{6}';FormField.create(hostIn(personal), { label: 'Badge number', control: badge, description: 'Six digits printed on your badge.' });
// Role.const role = annotate(fieldset('Role'), ['form', 'error-summary', 'validation-message', 'fieldset', 'select', 'combobox', 'radio-group', 'number-input', 'slider', 'multi-select']);const department = Select.create(hostIn(role), { label: 'Department', name: 'department', options: DEPARTMENTS, placeholder: 'Choose a department', required: true });const manager = Combobox.create(hostIn(role), { label: 'Manager', name: 'manager', options: MANAGERS, placeholder: 'Type a name', description: 'Search by first or last name.' });const type = RadioGroup.create(hostIn(role), { label: 'Employment type', name: 'type', orientation: 'horizontal', required: true, options: [{ value: 'full', label: 'Full time' }, { value: 'part', label: 'Part time' }, { value: 'contract', label: 'Contractor' }] });const salary = NumberInput.create(hostIn(role), { label: 'Annual salary', name: 'salary', min: 10000, max: 500000, step: 1000, format: { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 } });const hours = Slider.create(hostIn(role), { label: 'Weekly hours', name: 'hours', min: 8, max: 48, step: 1, largeStep: 4, value: 40, marks: [{ value: 20, label: '20' }, { value: 40, label: '40' }], showValue: true });const skills = MultiSelect.create(hostIn(role), { label: 'Skills', name: 'skills', options: SKILLS, maxSelected: 5, description: 'Up to five.' });
// Preferences.const prefs = annotate(fieldset('Preferences', 'You can change these later in settings.'), ['form', 'error-summary', 'fieldset', 'checkbox-group', 'switch', 'checkbox']);const benefits = CheckboxGroup.create(hostIn(prefs), { label: 'Benefits', name: 'benefits', orientation: 'horizontal', options: [{ value: 'health', label: 'Health' }, { value: 'pension', label: 'Pension' }, { value: 'transit', label: 'Transit pass' }, { value: 'gym', label: 'Gym' }] });const remote = Switch.create(hostIn(prefs), { label: 'Works remotely', name: 'remote' });const terms = Checkbox.create(hostIn(prefs), { label: 'I confirm these details are correct', name: 'terms', required: true });
// A standalone validation message for a rule that is not tied to one control.const actions = annotate(hostIn(form), ['form', 'error-summary', 'validation-message']);actions.className = 'sc-form__actions';const hint = ValidationMessage.create(hostIn(actions), { tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });
const buttons = hostIn(actions);buttons.className = 'sc-form__buttons';const submit = Button.create({ text: 'Save profile', variant: 'primary', type: 'submit' }, document);const reset = Button.create({ text: 'Reset', variant: 'secondary', type: 'reset' }, document);buttons.append(submit.element, reset.element);
const formController = Form.create(form, { summaryTitle: 'Fix these fields to save the profile', rules: [ { fields: ['type', 'hours'], validate: (values) => (values.type === 'part' && Number(values.hours) > 32 ? 'Part-time employees work at most 32 hours per week.' : null), }, ],});
form.addEventListener('aui-submit', (e) => { const { values } = (e as CustomEvent<FormSubmitDetail>).detail; submit.setLoading(true); // A save takes a moment; the button stays busy and focusable meanwhile. setTimeout(() => { submit.setLoading(false); hint.update({ tone: 'success', message: `Saved the profile of ${typeof values.name === 'string' ? values.name : 'the employee'}.` }); }, 600);});form.addEventListener('aui-reset', () => { hint.update({ tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });});
sc.listen(form, ['aui-submit', 'aui-invalid', 'aui-reset'], 'form');for (const [label, host] of [ ['name', name.host], ['email', email.host], ['department', department.host], ['manager', manager.host], ['type', type.host], ['salary', salary.host], ['hours', hours.host], ['skills', skills.host], ['benefits', benefits.host], ['remote', remote.host], ['terms', terms.host],] as const) { sc.listen(host, ['aui-change'], label);}
// Options.const all = [name, email, phone, bio, department, manager, type, salary, hours, skills, benefits, remote, terms];toggle(sc, 'Disabled', false, (disabled) => { for (const c of all) c.update({ disabled }); badge.disabled = disabled; submit.update({ disabled });});toggle(sc, 'Read-only', false, (readOnly) => { for (const c of [name, email, phone, bio, department, manager, salary, skills]) c.update({ readOnly }); badge.readOnly = readOnly;});choice( sc, 'Validate', [ { value: 'blur', label: 'When leaving a field' }, { value: 'input', label: 'While typing' }, { value: 'submit', label: 'On submit only' }, ], 'blur', (timing) => { for (const c of [name, email, phone, bio, department, type, salary, benefits, terms]) c.update({ validationTiming: timing }); },);action(sc, 'Fill sample data', () => { name.setValue('Ada Lovelace'); email.setValue('ada@example.com'); phone.setValue('+44 20 7946 0000'); bio.setValue('Writes the first programs and reviews every pull request.'); badge.value = '204816'; department.setValue('eng'); manager.setValue('chen-wei'); type.setValue('full'); salary.setValue(86000); hours.setValue(38); skills.setValue(['typescript', 'accessibility']); benefits.setValue(['health', 'pension']); remote.setChecked(true); terms.setChecked(true); sc.log('sample data filled');});action(sc, 'Submit empty', () => { formController.reset(); formController.submit();}, ['form', 'error-summary']);Address group with a group error
Section titled “Address group with a group error”import { Fieldset } from '@absoluteui/components/fieldset';import { TextInput } from '@absoluteui/components/text-input';import { Button } from '@absoluteui/components/button';
const element = document.createElement('fieldset');const streetHost = document.createElement('div');const cityHost = document.createElement('div');element.append(streetHost, cityHost);const check = document.createElement('button');check.type = 'button';check.textContent = 'Check address';Button.enhance(check);document.body.append(element, check);const street = TextInput.create(streetHost, { label: 'Street', autocomplete: 'address-line1' });const city = TextInput.create(cityHost, { label: 'City', autocomplete: 'address-level2' });const address = Fieldset.enhance(element, { legend: 'Delivery address', description: 'Where we send the order', required: true });check.addEventListener('click', () => { const missing = street.value.trim() === '' || city.value.trim() === ''; address.update({ error: missing ? 'Enter a street and a city' : null }); if (missing) address.focus();});Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { Fieldset } from '@absoluteui/components/fieldset';import '@absoluteui/components/fieldset/style.css';First use
Section titled “First use”import { Fieldset } from '@absoluteui/components/fieldset';import '@absoluteui/components/fieldset/style.css';
const element = document.querySelector<HTMLFieldSetElement>('#birth-date');if (element) Fieldset.enhance(element, { legend: 'Date of birth', description: 'For example, 27 3 2007' });More usage
import { Fieldset } from '@absoluteui/components/fieldset';import { ErrorSummary } from '@absoluteui/components/error-summary';
const element = document.querySelector<HTMLFieldSetElement>('#contact');const summaryHost = document.querySelector<HTMLElement>('#summary');if (element && summaryHost) { const contact = Fieldset.enhance(element, { legend: 'How should we contact you?', required: true }); const summary = ErrorSummary.create(summaryHost); const message = 'Choose at least one way to contact you'; contact.update({ error: message }); summary.show([{ message, target: contact.legend, focus: () => { contact.focus(); } }]);}Using Angular? See Fieldset for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”Fieldset.enhance(element: HTMLFieldSetElement, options: FieldsetOptions): FieldsetGlobal configuration key: fieldset (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
legend |
string |
Visible legend; the group’s accessible name. Required. | |
hideLegend |
boolean |
"false" |
Visually hide the legend (it stays the accessible name). |
description |
string |
Help text for the group, referenced by aria-describedby. | |
required |
boolean |
"false" |
Required marker; ‘(required)’ is added to the spoken legend. |
disabled |
boolean |
Sets the native disabled attribute; unset leaves it alone. | |
error |
string | null |
Group-level error message; empty or null hides it. | |
icons |
Partial<FieldsetIcons> |
Icon slot overrides. | |
locale |
string |
"en-US" |
Locale of the required text. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
element |
HTMLFieldSetElement |
The enhanced fieldset. |
legend |
HTMLLegendElement |
The rendered legend. |
options |
Readonly<FieldsetOptions> |
Current options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
focus(): void |
Focus the first enabled, visible control in the group (pass as an Error Summary item’s focus). |
update(options: Partial<FieldsetOptions>): void |
Merge and apply options. |
destroy(): void |
Remove the legend, help, and error; restore a page legend and aria-describedby. |
Content areas
Section titled “Content areas”| Area | Description |
|---|---|
controls |
The fieldset’s own children (any controls); they stay in place after the legend, help, and error. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-fieldset |
The enhanced fieldset. |
aui-fieldset--invalid |
A group error is shown. |
aui-field__label |
Legend (shared field chrome). |
aui-field__required |
Visual required marker. |
aui-field__description |
Help text. |
aui-field__error |
Group error message. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
error |
alert-circle |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-color-error-fg | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-font-weight-semibold | --aui-icon-size-sm | --aui-line-height-tight | --aui-space-1 | --aui-space-3
TypeScript definitions
interface FieldsetIcons { error: IconRef }interface FieldsetOptions { legend: string; hideLegend?: boolean; description?: string; required?: boolean; disabled?: boolean; error?: string | null; locale?: string; icons?: Partial<FieldsetIcons>;}Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Native fieldset and legend (HTML grouping): the legend names the group; help and the group error are referenced by aria-describedby.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Tab | Controls inside | Moves through the group’s controls in document order (the fieldset itself is not focusable). |
| Element | Role |
|---|---|
| fieldset | group (native) |
| legend | names the group (native) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
fieldset | help and error ids while shown, followed by the page’s own ids |
aria-hidden |
required asterisk | true; ‘(required)’ is spoken with the legend instead |
Never takes focus itself. focus() moves focus to the first enabled control, for Error Summary links.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”| Criterion | Level | Note |
|---|---|---|
| 1.3.1 Info and Relationships | A | |
| 2.4.6 Headings and Labels | AA | |
| 3.3.1 Error Identification | A | |
| 3.3.2 Labels or Instructions | A | |
| 4.1.2 Name, Role, Value | A |
Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- The group role cannot carry aria-required, so required state is spoken as part of the legend.
- Native disabled removes every native control inside from the tab order.
- Screen readers differ in how often they repeat the legend when moving between controls; keep legends short.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/fieldset |
34.6 kB | 11.9 kB | 10.6 kB | 0.5 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| Fieldset.enhance, per instance | < 1 ms average in headless Chromium |
Tested scale: Unit-tested per instance; not data-driven.
Constant work per render.
Measured run times: Performance.
Details
Section titled “Details”States
Default, required, invalid (group error shown), disabled (native), legend hidden.
State transitions
| From | Trigger | To |
|---|---|---|
| valid | update({ error: 'message' }) |
invalid; the message is added to aria-describedby |
| invalid | update({ error: null }) |
valid |
| any | update({ disabled }) |
native disabled on or off |
| any | destroy() |
the page’s fieldset as it was |
Accessibility notes
- Keep legends short: screen readers may repeat them when moving between the controls.
- Show the group error next to the group and in the Error Summary; use
focus()as the summary item’sfocus. - The e2e axe run covers three themes; manual screen-reader verification is pending.
Responsive behavior
A grid of the legend, help, error, and the page’s controls; the controls keep their own layout.
Right-to-left
Logical properties: the error bar sits at the inline start.
Theming
The shared field chrome follows the theme; forced-colors mode uses system colors for text and the error bar.
Global configuration
Only the inherited locale is configurable:
configureAbsoluteUI({ components: { fieldset: { locale: 'de-DE' } } });Component configuration
The instance locale overrides configuration; configuration changes re-render existing fieldsets.
Icons
icons.error (default alert-circle), shown with the group error.
Security
Legend, help, and error text use textContent; they are never parsed as HTML.
Data handling
No persistence, network access, or telemetry. The fieldset holds no values; its controls do.
Supported data scale
Not data-driven.
Edge cases
- A legend already in the fieldset is removed while enhanced and restored by
destroy(). disabledleft unset never touches the native attribute, so[disabled]bindings of frameworks keep working.focus()skips disabled and hidden controls; it does nothing when none is focusable.
Errors
| Code | Category | Cause |
|---|---|---|
FIELDSET_HOST |
configuration | The element is not a <fieldset>. |
FIELDSET_OPTIONS |
configuration | Missing or blank legend, or an option of the wrong type. |
ICON_UNKNOWN |
configuration | Unknown icon override. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid or unknown configuration. |
Invalid options throw before the fieldset is modified; an invalid update() leaves the previous state intact.
Known limitations
- Fieldset does not validate its controls; the application sets the group error (for example from Form validation).
- Manual screen-reader verification is pending.
Unsupported scenarios
- Collapsing the group: use Collapsible or Accordion.
- HTML in the legend.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.