Skip to content
HomeCobalt

Input

Takes one line of typed text, such as a name, an address or a search term.

Examples

A field named by its label, with an example in the placeholder.
Checked on submitSave checks both fields, puts each error under its field and moves focus to the first.

With an icon and a buttonA search field with its glyph inside the box and a Clear button once there is text.
In a fieldIts label, description and error are wired to the input.

Shown beside everything you post.

Variants

Align

stays.example/

Use letters, numbers and hyphens.

StartBefore the text, for a glyph or a fixed prefix such as a site address.

Type

EmailAn address brings the keyboard with the @ sign and the browser's address check.
PasswordThe autocomplete token tells the password manager what goes here, and the eye at the end shows the password while it is on.
SearchA large search field named by aria-label, with no visible label.
Phone numberA phone number brings the dial pad.
Web addressA web address brings the keyboard with the slash and the dot.

States

DisabledThe value stays at half opacity and takes no input.
Start with the country code, such as +44 20 7946 0000.
InvalidAfter a check, the red wash on the box and the error under it.

Your workspace owner can change it.

Read onlyFocusable and copyable at full opacity, but not editable.

Usage

Use it when

  • You type one line: a name, an address, a code, a search term.
  • The value is free text the system cannot list as options.
  • Something belongs inside the box: a search glyph, a fixed prefix such as a site address, or one action on the text such as Clear or Show. Use an InputGroup.

Use something else when

  • The text runs past one line, such as notes or an agenda. Use Textarea instead.
  • The value is one of up to 10 known options. Use Select instead; 2 to 4 options that fit in a row use SegmentedControl instead.
  • The text picks from a long list of values. Use Combobox instead.
  • The value is a count or an amount with a unit, such as nights or a price. Use NumberField instead, whose format writes the unit.
  • The value is a day. Use DatePicker instead, with typed for a birth date or a day years away.
  • The value is a file. Use FileDrop instead.
  • The field needs a description or an error. Use Field instead, which holds the Input and wires both to it.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/input.json https://kaanarici.com/r/cobalt/input-group.json
import { Input } from "@/components/cobalt/ui/input"
import { InputGroup, InputGroupInput, InputGroupAddon, InputGroupButton } from "@/components/cobalt/ui/input-group"