Skip to content
Nana UI

Input

View .md Download

A text input with label, helper text, validation, prefix/suffix and clear support.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/input";
<nana-input label="Email" placeholder="you@example.com" style="min-width:16rem"></nana-input>

Slot an icon (or any content) into the prefix / suffix slots.

Properties

PropertyAttributeTypeDefaultDescription
autocompleteHTMLInputElement['autocomplete']'off'
clearablebooleanfalse
disabledbooleanfalse
errorMessageerror-messagestring''
helperTexthelper-textstring''
inputId`nana-input-${Math.random().toString(36).slice(2, 7)}`
inputModeinputmodestring''Which virtual keyboard to raise on touch devices. Distinct from `type`: `type="text" inputmode="decimal"` keeps free-form input while still opening a numeric pad, which is what amount and phone fields want. `inputMode` is also a global HTMLElement property, so this deliberately overrides it: on the host it is inert (the host is not editable), and the value only does anything once forwarded to the inner `` below.
invalidbooleanfalse
labelstring''
loadingbooleanfalse
maxstring | undefinedUpper bound for `type="number"` / `type="date"` and friends.
maxlengthnumber | undefined
minstring | undefinedLower bound for `type="number"` / `type="date"` and friends.
minlengthnumber | undefined
namestring''
patternstring | undefinedRegular expression the value must match, per native constraint validation.
placeholderstring''
readonlybooleanfalse
requiredbooleanfalse
size'xs' | 'sm' | 'md' | 'lg''md'
stepstring | undefinedGranularity of the accepted value; `any` disables stepping.
typeHTMLInputElement['type']'text'
valuestring''

Events

EventDescription
nana-inputFired on every keystroke (`detail.value`)
nana-changeFired when the value is committed (`detail.value`)
nana-clearFired when the clear button or Escape empties the field
nana-focusFired when the field gains focus
nana-blurFired when the field loses focus

Slots

SlotDescription
prefixContent before the field, in a fixed-width zone
suffixContent after the field, in a fixed-width zone

CSS parts

PartDescription
::part(wrapper)The bordered field container
::part(input)The native `<input>` element

CSS custom properties

PropertyDescription
--nana-input-bgField background colour
--nana-input-colorInput text colour
--nana-input-radiusField corner radius
--nana-input-heightField height (defaults to the size preset)
--nana-input-affix-insetGap from the border to a slotted prefix/suffix
--nana-input-affix-gapGap between a slotted prefix/suffix and the text
--nana-input-affix-zoneReserved width for a slotted prefix/suffix
--nana-input-affix-icon-sizeSize applied to a slotted icon, svg or img
VariableDefaultDescription
--nana-input-bgField background colour
--nana-input-colorInput text colour
--nana-input-radiusField corner radius
PartDescription
wrapperThe bordered field container
inputThe native <input> element
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Input interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook