Fieldset
Groups related form controls in a native fieldset with a legend, drawn as a bordered box or a card.
<arc-fieldset>Overview
Fieldset groups related form controls inside a native <fieldset> with a <legend>, so screen readers announce them as one named group. Set the legend with the legend prop, or with the legend slot for markup. description adds helper text under the legend.
The default variant is a bordered box with rounded corners, and variant="card" adds a surface background and a small shadow. error shows a message below the controls with role="alert", for group-level problems such as "Select at least one option". The actions slot puts buttons or links, such as "Select all" or "Reset", on the legend's line.
disabled dims the group to 50% opacity and sets disabled on every ARC form control inside it, however deeply nested. A control added as a direct child while it's disabled is disabled too; one added inside a wrapper element is only picked up the next time disabled changes. Re-enabling it removes disabled only from the controls it set, so a control you disabled yourself stays disabled. Buttons aren't covered, arc-button or native, and neither are native inputs: the inner <fieldset> is in the shadow root and slotted children aren't its descendants, so disable those yourself.
Guidelines
Do
- Group inputs that share one label, such as the fields of a shipping address
- Use the card variant to set sections apart on a settings page
- Give every fieldset a legend. It's the group's accessible name
Don't
- Don't use it only for looks. Use a `div` or `arc-card`
- Don't put a single field's error in the fieldset's `error`. Attach it to that input
Features
- CSS parts: `fieldset`, `legend`, `description`, `content`, `error`
Preview
Usage
<arc-fieldset legend="Contact info" description="We'll use this to reach you.">
<arc-label for="email" required>Email</arc-label>
<arc-input id="email" type="email" placeholder="you@example.com"></arc-input>
<arc-label for="phone">Phone</arc-label>
<arc-input id="phone" type="tel" placeholder="(555) 123-4567"></arc-input>
</arc-fieldset>
<!-- Card variant with error -->
<arc-fieldset legend="Preferences" variant="card" error="Please select at least one option.">
<arc-checkbox label="Option A"></arc-checkbox>
<arc-checkbox label="Option B"></arc-checkbox>
</arc-fieldset>import { Fieldset, Label, Input, Checkbox } from '@arclux/arc-ui-react';
export default function Example() {
return (
<Fieldset legend="Contact info" description="We'll use this to reach you.">
<Label htmlFor="email" required>Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
<Label htmlFor="phone">Phone</Label>
<Input id="phone" type="tel" placeholder="(555) 123-4567" />
</Fieldset>
);
}<script setup>
import { Fieldset, Label, Input } from '@arclux/arc-ui-vue';
</script>
<template>
<Fieldset legend="Contact info" description="We'll use this to reach you.">
<Label for="email" required>Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</Fieldset>
</template><script>
import { Fieldset, Label, Input } from '@arclux/arc-ui-svelte';
</script>
<Fieldset legend="Contact info" description="We'll use this to reach you.">
<Label for="email" required>Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</Fieldset>import { Component } from '@angular/core';
import { Fieldset, Label, Input } from '@arclux/arc-ui-angular';
@Component({
imports: [Fieldset, Label, Input],
template: `
<arc-fieldset legend="Contact info" description="We'll use this to reach you.">
<arc-label for="email" required>Email</arc-label>
<arc-input id="email" type="email" placeholder="you@example.com" />
</arc-fieldset>
`,
})
export class ContactForm {}import { Fieldset, Label, Input } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<Fieldset legend="Contact info" description="We'll use this to reach you.">
<Label for="email" required>Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</Fieldset>
);
}import { Fieldset, Label, Input } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<Fieldset legend="Contact info" description="We'll use this to reach you.">
<Label for="email" required>Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</Fieldset>
);
}<!-- Use native <fieldset> and <legend> -->
<fieldset class="arc-fieldset" style="border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 16px 24px 24px;">
<legend style="font-weight: 600; color: var(--text-primary); padding: 0 4px;">Contact info</legend>
<p style="font-size: 14px; color: var(--text-muted);">We'll use this to reach you.</p>
<!-- inputs here -->
</fieldset><fieldset style="border: 1px solid rgb(42, 42, 52); border-radius: 10px; padding: 16px 24px 24px; margin: 0;">
<legend style="font-weight: 600; color: rgb(224, 224, 232); padding: 0 4px;">Contact info</legend>
<!-- inputs here -->
</fieldset>API
legendstring''- Text displayed in the
<legend>element. Also available via thelegendslot for markup. descriptionstring''- Helper text displayed below the legend.
errorstring''- Error message displayed below the content with
role="alert". disabledbooleanfalse- Dims the fieldset and disables every ARC form control inside it, at any depth, and a control slotted in directly while it is disabled. Re-enabling it re-enables only the controls it disabled, so a control that was already disabled stays disabled.
variant'default' | 'card''default'- Visual style. Card adds a surface background and shadow.
See also
- LabelForm label with a required indicator, description text and a tooltip slot. Clicking it focuses the control whose id is in `for`.
- FormWraps ARC UI inputs in a form that validates them on submit and fires arc-submit with their values.
- Switch GroupGroups toggle switches under one label and sets their size and disabled state together. Lays them out vertically or horizontally.