Skip to main content

Input

A labeled field for a short typed value.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Search and edit fields.

  • 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 Dense data uses it​

Field label or column header
Use type.label
Not type.heading
Headers repeat on every column; a heavy style would compete with the data.

Words​

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

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

Dense data 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)Lightslate.light.0:#FFFFFFDarkslate.dark.50:#161B23
Text
Changes with theme
component.input.textcolor.text.primaryvar(--input-text)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Placeholder
Changes with theme
component.input.placeholdercolor.text.mutedvar(--input-placeholder)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Heightcomponent.input.heightsize.control.defaultvar(--input-height)size.32:2rem
Padding, left and rightcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.12:0.75rem
Cornercomponent.input.radiusradius.controlvar(--input-radius)radius.2:0.125rem
Text sizecomponent.input.font-sizetype.body.font-sizevar(--input-font-size)font.size.14:0.875rem
Font familycomponent.input.font-familytype.body.font-familyvar(--input-font-family)font.family.ibm-plex-sans:"IBM Plex Sans", system-ui, sans-serif
Border widthcomponent.input.border-widthborder-width.defaultvar(--input-border-width)border-width.1:1px
Focus
on focus
component.input.focusborder-width.focusvar(--input-focus)border-width.2:2px
Canvas
Changes with theme
on focus
component.input.canvascolor.surface.canvasvar(--input-canvas)Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117
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)Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD
Focus
Changes with theme
on focus
component.input.border.focuscolor.border.focusvar(--input-border-focus)Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6
Disabled
Fill
Changes with theme
when disabled
component.input.disabled.backgroundcolor.disabled.surfacevar(--input-disabled-background)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Border
Changes with theme
when disabled
component.input.disabled.bordercolor.disabled.bordervar(--input-disabled-border)Lightslate.light.200:#DDE2EADarkslate.dark.200:#3D4655
Text
Changes with theme
when disabled
component.input.disabled.textcolor.disabled.textvar(--input-disabled-text)Lightslate.light.500:#6B7585Darkslate.dark.500:#C4CBD6