Input
A text input with a hairline border. Use it alone, with icons and addons in an InputGroup, or inside a Field.
Usage
import { Input, InputAddon, InputGroup } from 'nyctoui/input'
<Input placeholder="Issue title" aria-label="Issue title" />
<InputGroup>
<InputAddon>…</InputAddon>
<Input aria-label="Search" />
</InputGroup>The input is as wide as its container. Without a Field around it there is no visible label, so pass an aria-label.
Good for
- Name and email on a sign-up form.
- A search field at the top of a list, with a search icon.
- A price or a URL with an addon such as “$” or “https://”.
- A share link with a Copy button attached.
Examples
Sizes
The same 24, 32 and 40px scale as buttons. On touch screens the text is 16px at every size, so iOS does not zoom in on focus.
With an icon
InputGroup draws the box and the focus ring; the Input inside it goes bare. Pressing an addon focuses the input, as with a native field.
Prefix
With a button
Controls inside the group stay interactive. A small button fits a medium group with a little end padding.
Disabled
Best practices
- Label every input. Hide the label only when the context is obvious, like a search field with its icon, and keep it for screen readers.
- Set
type,inputMode,autoCompleteandenterKeyHint, so phones show the right keyboard and browsers fill it in. - Size the input to what goes in it: narrow for a ZIP code, wide for a URL.
- Use an
InputGroupwith anInputAddonfor a unit or a prefix, so the format is clear.
- Use the placeholder as the label.
- Use an input for several lines of text. Use a textarea.
- Put two inputs in one input group. Give each its own field.
API reference
Input
Wraps ui-sdk’s Input and takes native input props. Inherits size from an InputGroup.
| Prop | Type | Default |
|---|---|---|
sizeControl height. Inside a group, the group’s size. | 'sm' | 'md' | 'lg' | 'md' |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
InputGroup
A <div> that draws the input box around an Input and its addons.
| Prop | Type | Default |
|---|---|---|
sizeSize of the group and the Input inside it. | 'sm' | 'md' | 'lg' | 'md' |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
InputAddon
A <span> for an icon, prefix, suffix or small control beside the Input.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |