Skip to main content

Overview

This page documents the core form control components built with Radix UI primitives and styled with Tailwind CSS. All components include focus states, validation states, and dark mode support.

Button

A versatile button component with multiple variants and sizes, built with @radix-ui/react-slot for composition.

Props

variant
string
Visual style variant:
  • default - Primary button with solid background
  • destructive - Destructive action (red)
  • outline - Outlined button with border
  • secondary - Secondary style
  • ghost - Transparent with hover effect
  • link - Text link style with underline
Default: "default"
size
string
Button size:
  • default - 36px height (h-9)
  • sm - 32px height (h-8)
  • lg - 40px height (h-10)
  • icon - Square 36px (size-9)
  • icon-sm - Square 32px (size-8)
  • icon-lg - Square 40px (size-10)
Default: "default"
asChild
boolean
When true, renders as a Slot component allowing composition with other elements (e.g., Next.js Link)Default: false
className
string
Additional CSS classes
Inherits all standard HTML <button> attributes.

Usage Examples

Basic Button

Button Sizes

Icon Buttons

Button with Icon

From TranscriptionForm (src/features/speech-to-text-playground/transcription-form.tsx:373)


Input

Text input field with focus and validation states.

Props

type
string
Input type (text, password, email, number, file, etc.)Default: "text"
className
string
Additional CSS classes
Inherits all standard HTML <input> attributes.

Features

  • Focus States: Blue ring on focus (focus-visible:ring-ring/50)
  • Validation States: Red border and ring when aria-invalid is set
  • Dark Mode: Semi-transparent background (dark:bg-input/30)
  • File Input Support: Styled file input button
  • Selection: Custom selection colors

Usage Examples

Text Input

Password Input

Number Input

File Input


Textarea

Multi-line text input with auto-resize support.

Props

className
string
Additional CSS classes
Inherits all standard HTML <textarea> attributes.

Features

  • Auto-resize: Uses field-sizing-content for automatic height adjustment
  • Minimum Height: Default min-h-16 (64px)
  • Focus States: Same as Input component
  • Validation States: Red border and ring when aria-invalid is set

Usage Example

From TranscriptionForm (src/features/speech-to-text-playground/transcription-form.tsx:290):

Label

Accessible label component built with @radix-ui/react-label.

Props

className
string
Additional CSS classes
Inherits all props from @radix-ui/react-label.

Features

  • Accessibility: Proper label-input association
  • Disabled States: Automatically styles when associated input is disabled
  • Flex Layout: Default flex items-center gap-2 for icon support
  • Non-selectable: Uses select-none to prevent text selection

Usage Examples

Basic Label

Label with Checkbox


Checkbox

Checkbox component built with @radix-ui/react-checkbox.

Props

checked
boolean | 'indeterminate'
Controlled checked state
onCheckedChange
(checked: boolean | 'indeterminate') => void
Callback fired when checked state changes
disabled
boolean
Disables the checkbox
className
string
Additional CSS classes
Inherits all props from @radix-ui/react-checkbox.

Features

  • Radix UI: Built on @radix-ui/react-checkbox for accessibility
  • Check Icon: Uses lucide-react Check icon
  • States: Supports checked, unchecked, and indeterminate states
  • Focus Ring: Visible focus indicator

Usage Example

From TranscriptionForm (src/features/speech-to-text-playground/transcription-form.tsx:312):

Select

Dropdown select component built with @radix-ui/react-select.

Components

The Select component is composed of multiple sub-components:
  • Select - Root component
  • SelectTrigger - Button that opens the dropdown
  • SelectValue - Displays selected value
  • SelectContent - Dropdown container
  • SelectItem - Individual option

Props

Select (Root)

value
string
Controlled selected value
onValueChange
(value: string) => void
Callback fired when selection changes
disabled
boolean
Disables the select

SelectTrigger

size
'sm' | 'default'
Trigger button size
  • default - 36px height (h-9)
  • sm - 32px height (h-8)
Default: "default"
className
string
Additional CSS classes

SelectContent

position
'popper' | 'item-aligned'
Positioning strategyDefault: "popper"
align
'start' | 'center' | 'end'
Alignment relative to triggerDefault: "center"

Features

  • Radix UI: Built on @radix-ui/react-select for accessibility
  • Icons: Uses lucide-react chevron icons
  • Scroll Buttons: Automatic scroll indicators for long lists
  • Animations: Smooth open/close animations
  • Dark Mode: Styled for dark backgrounds

Usage Example

From TranscriptionForm (src/features/speech-to-text-playground/transcription-form.tsx:194):

Select with Icons


Styling

All form components use consistent styling patterns:

Focus States

Validation States

Dark Mode

Disabled States

TypeScript Interfaces

Button Variants (from class-variance-authority)

Component Props

Radix UI Integration

These components integrate the following Radix UI primitives:
  • Button: @radix-ui/react-slot for composition
  • Label: @radix-ui/react-label for accessibility
  • Checkbox: @radix-ui/react-checkbox for state management
  • Select: @radix-ui/react-select for dropdown functionality

Why Radix UI?

  • Accessibility: WAI-ARIA compliant components
  • Unstyled: Full control over styling with Tailwind CSS
  • Composable: Flexible component APIs
  • Keyboard Navigation: Built-in keyboard support

Accessibility

  • All form controls support proper label association
  • Focus states are clearly visible
  • Error states use aria-invalid attribute
  • Keyboard navigation fully supported
  • Screen reader friendly with proper ARIA attributes