Skip to content

Internal ID software / Forms

FormField

A label, a control and the one message under it, wired together.

Not drawn in Figma: built only from the tokens, for internal ID software. In code: components/software/form.tsx. From the old system: FormField in @id-identity-as/ui/form.

Example

Vælg hele uger.

Vælg hele uger.

import { FormField } from '@/components/software/form';

<FormField id="period" label="Periode" helper="Vælg hele uger.">
  <input id="period" name="period" type="week" />
</FormField>

Props

PropTypeDefaultWhat it does
id (required)stringThe id of the control inside. Give the control the same id.
label (required)stringThe visible label.
helperstringGuidance shown under the field when there is no error.
errorstringWhat to do about a problem. Replaces the helper.
requiredbooleanRequired fields carry no mark. The optional ones are marked.
optionalLabelstring'(valgfrit)'The mark on an optional field.

Do

  • Use it for a control this set does not cover, such as a date or a file.
  • Point the control at the message yourself: aria-describedby="{id}-helper" or "{id}-error".

Do not

  • Do not use it around Input, Textarea or Select. They bring their own.
  • Do not mark the required fields with an asterisk. The optional ones carry the mark.

Accessibility

  • The label is tied to the control by id.
  • The error has the id "{id}-error" and the helper "{id}-helper".

Tokens it uses

  • color.text.default
  • color.software.muted
  • type.heading.sm
  • type.body.sm
  • space.inline.2