The Action Button component provides a seamless way to handle loading states in forms and async operations. Perfect for form submissions, data fetching, and any action that requires user feedback.
Installation
Examples
Default
Secondary
Destructive
Outline
Ghost
Link
Usage
Basic Usage
Form Integration
Customization
Custom Loading Indicator
Custom Variants
With Icon
Notes
- Built on top of the base Button component
- Uses Lucide React for loading spinner
- TypeScript support with proper types
- Maintains width during loading state
- Prevents accidental double submissions
- Supports all button variants and sizes
- Integrates with Shadcn UI components
- Optimized for form submissions
Features
- Smooth loading state transitions
- Consistent button width
- Prevents form resubmission
- Multiple button variants
- Responsive sizing options
- Accessible loading states
- Form integration support
- Server actions compatibility
Props
Prop | Type | Description |
---|---|---|
isPending | boolean | Whether the button is in a loading state |
onClick | () => void | Optional click handler that prevents default form submission |
variant | "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | The visual variant of the button |
size | "default" | "sm" | "lg" | "icon" | The size of the button |
children | React.ReactNode | The content to display inside the button |