Skip to content

FormControl

Form control wrapper component with theme-aware styling that handles input focus and validation

Uses CSS custom properties from @sparkle/theme for consistent theming across light/dark modes. Primarily a pass-through wrapper for Radix Form.Control.

import { FormControl } from '@sparkle/ui'
PropTypeRequiredDefaultDescription
asChildboolean | undefinedUse the child component as the control element
size"sm" | "md" | "lg" | undefinedSize variant for the control
validationState"default" | "success" | "error" | undefinedValidation state for styling
disabledboolean | undefinedWhether the control is disabled

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.