Skip to content

FormInput

Form input component with theme-aware styling for different input types with proper accessibility

Uses CSS custom properties from @sparkle/theme for consistent theming across light/dark modes and supports validation states with semantic colors.

import { FormInput } from '@sparkle/ui'
PropTypeRequiredDefaultDescription
type"number" | "text" | "email" | "password" | "tel" | "url" | "search" | undefinedInput type
size"sm" | "md" | "lg" | undefinedSize variant for the input
validationState"default" | "success" | "error" | undefinedValidation state for styling
placeholderstring | undefinedInput placeholder text
disabledboolean | undefinedWhether the field is disabled
requiredboolean | undefinedWhether the field is required
valuestring | undefinedInput value
onChange((event: React.ChangeEvent<HTMLInputElement>) => void) | undefinedInput change handler
onFocus((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefinedInput focus handler
onBlur((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefinedInput blur handler
onKeyDown((event: React.KeyboardEvent<HTMLInputElement>) => void) | undefinedInput key down handler for keyboard navigation

This component uses CSS custom properties from @sparkle/theme for consistent styling across light and dark modes.

  • --theme-*: Uses theme design tokens for consistent styling

You can customize the appearance by:

  1. Theme Variables: Modify theme tokens in your @sparkle/theme configuration
  2. CSS Classes: Apply custom CSS classes via the className prop
  3. CSS-in-JS: Use styled-components or emotion with the component

This component follows accessibility best practices with proper ARIA attributes and keyboard support.