Text field
Form-associated text field with a comet of light on the border while focused; invalid values turn the border to static.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfInput label="Work email" hint="We’ll send the invite here" name="email" type="email" placeholder="you@company.com" required />
Installation
pnpm dlx shadcn@latest add @lumesec/hf-inputFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/hf-input.jsonUsage
import { HfInput } from "@/components/lumesec/hf-input";
export function Example() {
return (
<HfInput name="email" label="Work email" type="email" required placeholder="you@company.com" hint="We’ll send the invite here" />
);
}Behaviour
A comet of light runs around the border while you type and sparks off the caret. Invalid input turns the border into static; a valid value gets a green sweep.
API reference
Attributes
labelReact proplabelTypestringVisible label, linked to the inner input. Hidden when absent.
valueReact propvalueTypestringInitial value. Also the value restored on form reset.
hintReact prophintTypestringText under the field when there is no error.
errorReact properrorTypestringMessage shown, and used as the validation message, when the value is invalid. Defaults to the browser validationMessage.
successReact propsuccessTypestringMessage shown when a valid value is committed on blur. Falls back to hint.
nameReact propnameTypestringForm field name.
typeReact proptypeTypestringPassed to the inner <input>, for example email, url or password.
placeholderReact propplaceholderTypestringPassed to the inner input.
requiredReact proprequiredTypebooleanDefaultfalsePresence attribute, passed to the inner input.
patternReact proppatternTypestringPassed to the inner input.
minlengthReact propminlengthTypenumberPassed to the inner input.
maxlengthReact propmaxlengthTypenumberPassed to the inner input.
autocompleteReact propautocompleteTypestringPassed to the inner input.
inputmodeReact propinputmodeTypestringPassed to the inner input.
spellcheckReact propspellcheckTypestringPassed to the inner input.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
inputReact proponInputDetail{ value: string }Fires on every edit.
changeReact proponChangeDetail{ value: string }Fires when the inner input commits a change, on blur after editing.
Methods
Call them on the element, for example through a React ref.
focus()Moves focus to the inner input.
Properties
valueTypestringCurrent text. Setting it updates the form value and validity, but not the visual state or message.
Accessibility
- A
<label for>in the shadow root names the inner<input>. - The hint, error and success text sits in an
aria-live="polite"region. - Sets
aria-invalidon the inner input when it validates on blur. - The host does not delegate focus; call
focus()on it to focus the input. - Submits the inner input value under
name. Validity mirrors the inner input constraints (required,type,pattern,minlength,maxlength) and reportscustomErrorwith theerrortext or the browser message. The error or success state appears on blur, and while in error it re-checks on every edit. Form reset restores thevalueattribute. - Reduced motion: the border comet stays in one place, the error static does not flicker, the caret sparks and error shake are skipped, and messages swap without rolling.
Theming
The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --card, --destructive, --foreground, --lumesec, --lumesec-success and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-danger, --ui-fg, --ui-muted, --ui-ok and --ui-surface.
Notes
- Attributes are read once on first connect and are not observed; use the
valueproperty afterwards. - The inner input's native
inputevent is composed, so aninputlistener on the host also receives that event (withoutdetail) in addition to the custom one.
Related
Was this page helpful?