Skip to main content

Input

A labeled field for a short typed value.

In Accessible first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Accessible first: Text answers.

  • Use it when: A name, email, phone number or other one-line answer.
  • Not when: Long text (textarea), or a closed choice (radio group, select or checkbox).

Instead:

How Accessible first uses it​

Field label or column header
Use type.label, above the field, always visible
Not A placeholder as the label
Labels must stay visible while typing.

Words​

  • Use common words. Explain any term you must use.
  • One idea per sentence. Put the action first.
  • Never blame the person.
  • Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.

The labels components use, from the voice tokens:

  • content.action.commit: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

Test before you ship:

  • A visible label, never a placeholder as the only label. undefined

Use it in code​

npx open-ds add input

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Input reads 17 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Input's tokens to change Input alone.

Changes with theme

Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Input
Fill
Changes with theme
component.input.backgroundcolor.surface.defaultvar(--input-background)Lightgray.light.0:#FFFFFFDarkgray.dark.50:#141414
Text
Changes with theme
component.input.textcolor.text.primaryvar(--input-text)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Placeholder
Changes with theme
component.input.placeholdercolor.text.mutedvar(--input-placeholder)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Heightcomponent.input.heightsize.control.defaultvar(--input-height)size.52:3.25rem
Padding, left and rightcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.24:1.5rem
Cornercomponent.input.radiusradius.controlvar(--input-radius)radius.6:0.375rem
Text sizecomponent.input.font-sizetype.body.font-sizevar(--input-font-size)font.size.19:1.1875rem
Font familycomponent.input.font-familytype.body.font-familyvar(--input-font-family)font.family.atkinson-hyperlegible:"Atkinson Hyperlegible", Verdana, sans-serif
Border widthcomponent.input.border-widthborder-width.defaultvar(--input-border-width)border-width.2:2px
Focus
on focus
component.input.focusborder-width.focusvar(--input-focus)border-width.3:3px
Canvas
Changes with theme
on focus
component.input.canvascolor.surface.canvasvar(--input-canvas)Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A
Danger
Changes with theme
when invalid
component.input.dangercolor.status.dangervar(--input-danger)Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B
Border
Color
Changes with theme
component.input.bordercolor.border.strongvar(--input-border)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Focus
Changes with theme
on focus
component.input.border.focuscolor.border.focusvar(--input-border-focus)Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8
Disabled
Fill
Changes with theme
when disabled
component.input.disabled.backgroundcolor.disabled.surfacevar(--input-disabled-background)Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222
Border
Changes with theme
when disabled
component.input.disabled.bordercolor.disabled.bordervar(--input-disabled-border)Lightgray.light.200:#D6D6D6Darkgray.dark.200:#333333
Text
Changes with theme
when disabled
component.input.disabled.textcolor.disabled.textvar(--input-disabled-text)Lightgray.light.500:#595959Darkgray.dark.500:#949494