# GroupLabel

> The group heading for sets of controls. With `as="legend"` as the first child of a `<fieldset>` it names the group, which is how FormField (and so CheckboxGroup), RadioGroup and the SelectableCard group render it; the default `as="label"` names one control through `htmlFor`.

- Status: stable
- Group: form
- Page: https://www.digitaltableteur.com/design-system/components/group-label
- Contract: https://www.digitaltableteur.com/contracts/v1/GroupLabel.contract.json

## When to use

GroupLabel is the one look for every group heading. Rendered as a legend inside a fieldset it names the whole group, and FormField, RadioGroup and the SelectableCard group already render it that way. Rendered as a label (the default) it points at one control through htmlFor, for the primary control of a composite input. For ordinary groups of same-name controls, use FormField or RadioGroup rather than wiring the fieldset yourself.

## When not to use

- Do not use as the label of an ordinary single input; that is `Label`. as="label" is for the primary control of a composite group.
- Do not style as a heading; screen readers will navigate to it as a heading and miss the group it labels.

## Look-alikes

- FormField: Do not name a radio or checkbox set with as="label"; a label names one control. Use as="legend" inside a fieldset, or FormField.
- Label: Do not use as the label of an ordinary single input; that is `Label`. as="label" is for the primary control of a composite group.

## Props

| Prop | Type | Default | Description | Required |
| --- | --- | --- | --- | --- |
| `as` | `"label" \| "legend"` | `label` | Element to render. legend (first child of a fieldset) names a group of controls; label names one control through htmlFor. | No |
| `htmlFor` | `string` | none | ID of the control the label names. Required for label; ignored for legend. | No |
| `tooltipText` | `string` | none | Optional browser tooltip; fallback when title is not set. | No |
| `required` | `boolean` | `false` | Shows the required asterisk. | No |
| `disabled` | `boolean` | `false` | Muted disabled styling. | No |
| `title` | `string` | none | Native title attribute override. | No |

## Variants

- Allowed `as` values: `label`, `legend` (default `label`).

## Invalid combinations

The contract records no invalid combinations.

## Keyboard

The contract records no keyboard interaction.

## Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

| Level | Rule | How it is checked |
| --- | --- | --- |
| MUST | ARIA: As="legend" as the first child of a `<fieldset>` gives the group its accessible name; a `<label>` inside a fieldset does not name the fieldset. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: As="label" (the default) names one control through htmlFor. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: The required asterisk is aria-hidden; the controls must expose the required state themselves. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by `npm run test:stories:matrix:ci`. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by `npm run test:stories:matrix:ci`. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by `npm run test:stories:hc`. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
| SHOULD | With as="label", point htmlFor at the control that should receive focus when the text is clicked. | Not stated in the contract. |
| SHOULD | Render as="legend" as the first child of a fieldset to name a group of controls. | Not stated in the contract. |
| SHOULD | Pair with required to show the asterisk when the underlying group must be filled; the asterisk is aria-hidden, so the controls carry the required state. | Not stated in the contract. |
| SHOULD | Keep the text a noun phrase (Delivery address), matching Label's tone. | Not stated in the contract. |
| SHOULD NOT | Do not name a radio or checkbox set with as="label"; a label names one control. Use as="legend" inside a fieldset, or FormField. | Not stated in the contract. |
| SHOULD NOT | Do not nest interactive elements inside it; as a label it forwards clicks to the target control. | Not stated in the contract. |

## Install and import

- Install: `npm install @digitaltableteur/react` (version 0.9.1, restricted access on npm).
- Import: `import { GroupLabel } from "@digitaltableteur/react";`
- Entry point: `@digitaltableteur/react/forms` exports it too.
- Styles: import `@digitaltableteur/react/style.css` once at the app boundary.
- Also available as the custom element `<dt-group-label>`; see the custom elements manifest.

## Links

- Machine-readable contract (Design System Contract 1.0): https://www.digitaltableteur.com/contracts/v1/GroupLabel.contract.json
- Markdown version of this page: https://www.digitaltableteur.com/design-system/components/group-label.md
- Component index as JSON: https://www.digitaltableteur.com/design-system/components.json
- All components: https://www.digitaltableteur.com/design-system/components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.
