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
| Prop | Type | Default | What it does |
|---|---|---|---|
label (required) | string | The visible label. Never a placeholder. | |
name (required) | string | The form field name. | |
autoComplete (required) | AutoCompleteToken | An HTML autocomplete token such as "email" or "organization", or "off" as the explicit refusal. | |
helper | string | Guidance shown under the field when there is no error. | |
error | string | What to do about a problem. Its presence puts the field in its error state. | |
required | boolean | Required fields carry no mark. The optional ones are marked. | |
optionalLabel | string | '(valgfrit)' | The mark on an optional field. Pass a translation here. |
...input | InputHTMLAttributes | Everything 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