A modern, accessible, and theme-aware button component for all UI actions. Highly flexible with variants, sizes, and an integrated loader, it is perfect for forms, dialogs, toolbars, and anywhere you need a robust action element.
radien
You can install the Button component with the following CLI command, or copy the implementation manually:
1npx shadcn@latest add http://localhost:3000/r/button.jsonTo use the Button component, import it in your code:
1import { Button } from '@/components/Button';The Button component accepts the following props:
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
variant | 'primary' | 'secondary' | 'gradient' | 'destructive' | 'primary' | Visual style of the button. | No |
size | 'sm' | 'md' | 'lg' | 'md' | Button size. | No |
loader | boolean | false | Show a spinning loader icon at the start, for loading state. | No |
className | string | - | Additional utility classes for customizing the button styling. | No |
children | React.ReactNode | - | The content inside the button. | Yes |
onClick | () => void | - | Callback fired when the button is clicked. | No |
1<Button onClick={() => alert('Clicked!')}>Click me</Button>1<Button loader>Loading...</Button>1<>
2 <Button variant="primary">Primary</Button>
3 <Button variant="secondary">Secondary</Button>
4 <Button variant="gradient">Gradient</Button>
5 <Button variant="destructive">Destructive</Button>
6</>1<>
2 <Button size="sm">Small</Button>
3 <Button size="md">Medium</Button>
4 <Button size="lg">Large</Button>
5</>className prop or edit the Tailwind classes.defaultVariants in the source for a new default look.@tabler/icons-react is installed.