Bonusway design system

Forms

Field

Label, help text and required marker around exactly one control. It generates the id and wires `aria-describedby` for you, which is why controls should not be labelled by hand.

import Field from '@/components/ui/Field';

Source: src/components/ui/Field.tsx

Examples

Label, help and required

Used only for withdrawals.

size="sm" — label and control shrink together

Props

<Field> props

PropTypeDefaultDescription
labelrequiredstring——
helpReactNode—

Helper text below the control, styled like the guide's `.input-metadata`.

requiredbooleanfalse

A control may still carry the native attribute alongside this prop, and several do: where the submit path validates nothing (login, password reset request, the SMS code), the browser's gate is the only thing standing between an empty box and a misleading answer. Those sites say so at the call. Drop the attribute once the handler reports the field itself.

size'sm' | 'md''md'

so a compact filter bar shrinks as a whole rather than control-only.

classNamestring''—
childrenrequiredReactElement<{ id?: string; 'aria-describedby'?: string; 'aria-required'?: boolean; }>—

Exactly one form control (Input, Select, Dropdown, …).

Accessibility

  • The label is associated with the control, so clicking it focuses the field.
  • Help text is referenced by aria-describedby, so it is read with the field rather than being decoration.

Usage

Do

  • Give it exactly one child. The id-and-describedby wiring assumes one control.

Don’t

  • Don’t use it around a Checkbox — a checkbox carries its own label, which is why Checkbox has a `required` prop of its own.
  • Don’t add your own htmlFor/id; you will fight the generated ones.

Denne webside bruger cookies

Vi bruger cookies til at forbedre din oplevelse på vores side og tilpasse det indhold, vi leverer til dig. Væsentlige cookies er nødvendige for at vores service kan fungere korrekt. Hvis du godkender, at vi indsamler oplysninger om dig gennem brug af nødvendige cookies og marketing-cookies, så vælg "Godkend alle cookies". Du kan altid ændre dine præferencer ved at besøge Cookie-indstillinger.

Cookie-indstillinger