API reference: @salmonui/inputs/otp-field
OtpFieldcomponent
import { OtpField } from '@salmonui/inputs/otp-field';function OtpField(props: OtpFieldProps): ReactNode;
One-time code input: one native <input autocomplete="one-time-code"> with maxLength, drawn as cells from the
value and the selection, so SMS autofill, paste and screen readers see a
single field. ref is the input; unknown props go to the input,
className / style to the root.
Props: OtpFieldProps
| Name | Signature | Description |
|---|---|---|
labeloptionalinherited | label?: ReactNode; | |
descriptionoptionalinherited | description?: ReactNode; | |
errorMessageoptionalinherited | errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode; | Error text (or a function of the errors) shown while the field is invalid. |
lengthoptional | readonly length?: number | undefined; | Number of cells. Default 4. |
typeoptional | readonly type?: 'numeric' | 'alphanumeric' | 'text' | undefined; | Accepted characters: digits (default), letters and digits, or any non-space character. |
maskoptional | readonly mask?: boolean | string | undefined; | Hides the characters (a password input, cells show |
valueoptional | readonly value?: string | undefined; | |
defaultValueoptional | readonly defaultValue?: string | undefined; | |
onValueChangeoptional | readonly onValueChange?: ((value: string, details: OtpChangeDetails) => void) | undefined; | |
onCompleteoptional | readonly onComplete?: ((value: string) => void) | undefined; | Fires when the value reaches |
placeholderoptional | readonly placeholder?: string | undefined; | One character repeated in every empty cell, or one character per cell. |
separatoroptional | readonly separator?: ReactNode; | Drawn between groups. |
groupSizeoptional | readonly groupSize?: number | undefined; | Cells per group; default 1 with a |
transformoptional | readonly transform?: 'uppercase' | 'lowercase' | 'none' | undefined; | Normalizes letters. Default |
localeTextoptional | readonly localeText?: OtpFieldLocaleText | undefined; | |
classNameoptional | readonly className?: string | undefined; | |
styleoptional | readonly style?: CSSProperties | undefined; | |
classNamesoptional | readonly classNames?: {
readonly cells?: string;
readonly cell?: string;
readonly input?: string;
readonly label?: string;
readonly description?: string;
readonly error?: string;
} | undefined; | Part classes: |
refoptional | readonly ref?: Ref<HTMLInputElement> | undefined; | The native |
invalidoptionalinherited | invalid?: boolean; | Forces the error state. |
validationoptionalinherited | validation?: FieldValidation; | Rules in the Data Grid vocabulary. |
validateOnoptionalinherited | validateOn?: ValidateOn; | When errors appear; default the |
sizeoptionalinherited | size?: FieldSize; | Metric set. Default |