Skip to content

Internal ID software / Forms

Input

A single line of text, with its label, its helper and its error.

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

Example

Otte cifre uden mellemrum.

Skriv en e-mailadresse, fx navn@firma.dk

Otte cifre uden mellemrum.

Skriv en e-mailadresse, fx navn@firma.dk

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

<Input label="Firma" name="company" autoComplete="organization" required />
<Input label="CVR-nummer" name="cvr" autoComplete="off" inputMode="numeric" helper="Otte cifre uden mellemrum." />
<Input label="E-mail" name="email" type="email" autoComplete="email" required error="Skriv en e-mailadresse, fx mette@firma.dk" />

Props

PropTypeDefaultWhat it does
label (required)stringThe visible label. Never a placeholder.
name (required)stringThe form field name.
autoComplete (required)AutoCompleteTokenAn HTML autocomplete token such as "email" or "organization", or "off" as the explicit refusal.
helperstringGuidance shown under the field when there is no error.
errorstringWhat to do about a problem. Its presence puts the field in its error state.
requiredbooleanRequired fields carry no mark. The optional ones are marked.
optionalLabelstring'(valgfrit)'The mark on an optional field. Pass a translation here.
...inputInputHTMLAttributesEverything a native input takes: type, inputMode, defaultValue, onChange, disabled.

Do

  • Choose the autocomplete token. "off" is a real answer for a number that belongs to one order.
  • Write the error as what to do: "Skriv alle 8 cifre", not "Ugyldigt CVR".
  • Set type and inputMode, so a phone shows the right keyboard.

Do not

  • Do not use the placeholder as the label.
  • Do not colour an error red. The edge doubles in the text colour and the message is set in the heading weight.
  • Do not post a form to DynamicWeb from a React field. DynamicWeb takes native inputs in its own templates.

Accessibility

  • A native input with a real label.
  • In error it has aria-invalid, and aria-describedby points at the error; otherwise at the helper. Never both.
  • The edge of the field is Stone: at least 3:1 against the surface in light and dark.

Tokens it uses

  • color.surface.base
  • color.text.default
  • color.neutral.500
  • color.software.muted
  • radius.sm
  • type.body.md
  • type.body.sm
  • type.heading.sm
  • space.inline.2
  • component.field.padding-top
  • component.field.padding-bottom
  • component.field.padding-x