Input hints
The keyboard, Enter key and autofill attributes that agree for a kind of value.
Reach for it for a sign-in, one-time code, search or address field that a phone fills in. The helpers are pure: no DOM at import time or in the call path, so they run on the server and in tests. Each result below is computed when the page is built, by running the call shown.
Import
import { inputHints, type InputHintKind, type InputHints, type EnterKeyHint } from '@ecopages/radiant-ui/helpers';Hints
inputHints(kind, { enter }) returns inputmode, enterkeyhint, autocomplete, autocapitalize, autocorrect and spellcheck, named as in HTML, for email, url, tel, one-time-code, numeric, decimal, search, name, username, postal-code, current-password and new-password. It leaves out what a kind has no value for, turns off autocorrect and spell checking, and capitalizes only name (by word) and postal-code (by character). enter sets the Enter key label; search defaults to search. It never sets type, pattern or validation: spread the result on the input and keep those yours.
<RuiInput type="email" name="email" {...inputHints('email', { enter: 'next' })} />| Call | Result |
|---|---|
inputHints('email') | {"inputmode":"email","autocomplete":"email","autocapitalize":"none","autocorrect":"off","spellcheck":"false"} |
inputHints('one-time-code', { enter: 'done' }) | {"inputmode":"numeric","autocomplete":"one-time-code","autocapitalize":"none","autocorrect":"off","spellcheck":"false","enterkeyhint":"done"} |
inputHints('search') | {"inputmode":"search","enterkeyhint":"search","autocapitalize":"none","autocorrect":"off","spellcheck":"false"} |
inputHints('new-password') | {"autocomplete":"new-password","autocapitalize":"none","autocorrect":"off","spellcheck":"false"} |