Skip to main content

Input

A labeled field for a short typed value.

In Content first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Content first: Search and the newsletter field.

  • 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 Content first uses it​

Field label or column header
Use type.label
Not type.caption
Caption is too faint for a label people must read.

Words​

  • Write to one person: "you", not "users".
  • Short sentences with room to breathe.
  • Explain why before asking for anything.
  • Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Browse guides

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

Content 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)Lightstone.light.0:#FFFFFFDarkstone.dark.50:#1F1B16
Text
Changes with theme
component.input.textcolor.text.primaryvar(--input-text)Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8
Placeholder
Changes with theme
component.input.placeholdercolor.text.mutedvar(--input-placeholder)Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B
Heightcomponent.input.heightsize.control.defaultvar(--input-height)size.48:3rem
Padding, left and rightcomponent.input.padding-xspace.inset.control-xvar(--input-padding-x)space.20:1.25rem
Cornercomponent.input.radiusradius.controlvar(--input-radius)radius.8:0.5rem
Text sizecomponent.input.font-sizetype.body.font-sizevar(--input-font-size)font.size.18:1.125rem
Font familycomponent.input.font-familytype.body.font-familyvar(--input-font-family)font.family.source-serif-4:"Source Serif 4", Georgia, 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)Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D
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)Lightstone.light.500:#7A7062Darkstone.dark.400:#A39A8B
Focus
Changes with theme
on focus
component.input.border.focuscolor.border.focusvar(--input-border-focus)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Disabled
Fill
Changes with theme
when disabled
component.input.disabled.backgroundcolor.disabled.surfacevar(--input-disabled-background)Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24
Border
Changes with theme
when disabled
component.input.disabled.bordercolor.disabled.bordervar(--input-disabled-border)Lightstone.light.200:#E4DDD0Darkstone.dark.200:#4A4339
Text
Changes with theme
when disabled
component.input.disabled.textcolor.disabled.textvar(--input-disabled-text)Lightstone.light.500:#7A7062Darkstone.dark.500:#CFC6B6