Button
A versatile button component supporting multiple variants, sizes, and custom animations.
Customize Your Button
Leave blank to use variant color
Leave blank for variant's text
Leave blank for variant's hover
Leave blank for variant's hover text
Only applies if size > 0
Installation
Install the button component using:
File Structure
Variants
Default
Secondary
Destructive
Outline
Ghost
Shine
Gooey Right
Gooey Left
Sizes
Props
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "ringHover" | "linkHover" | "expandIcon" | "shine" | "gooeyRight" | "gooeyLeft" | "default" |
size | "default" | "sm" | "lg" | "icon" | "default" |
asChild | boolean | false |
Features
The Button component provides the following features:
- Dynamic Variants:
- Supports multiple styles such as
default,secondary,destructive,outline,ghost, and more.
- Supports multiple styles such as
- Custom Animations:
- Includes unique hover effects like
shine,gooeyRight, andexpandIconfor enhanced interactivity.
- Includes unique hover effects like
- Multiple Sizes:
- Available in
small,default,large, andiconsizes to fit various use cases.
- Available in
- Accessibility Built-In:
- Fully supports ARIA attributes, focus states, and keyboard navigation.
- Customizable:
- Highly extensible with custom class names and the
asChildprop for wrapping elements.
- Highly extensible with custom class names and the
Use Cases
The Button component is ideal for:
- Call-to-Actions:
- Use prominent buttons like
defaultorshinefor primary actions such as signing up or submitting forms.
- Use prominent buttons like
- Destructive Actions:
- Highlight critical actions such as deletions with the
destructivevariant.
- Highlight critical actions such as deletions with the
- Secondary Actions:
- Pair primary buttons with subtle options like
secondaryfor less prominent actions.
- Pair primary buttons with subtle options like
- Toolbars and Icon Buttons:
- Use the
iconsize for compact buttons in toolbars or quick actions.
- Use the
- Dynamic UIs:
- Enhance user interfaces with interactive effects like
ringHoverorexpandIcon.
- Enhance user interfaces with interactive effects like
Accessibility
The Button component is built with accessibility in mind:
- ARIA Roles:
- Supports attributes like
aria-label,aria-labelledby, andaria-expandedfor screen readers.
- Supports attributes like
- Keyboard Navigation:
- Fully operable using
TabandEnterkeys.
- Fully operable using
- Focus Management:
- Includes focus-visible styles to indicate active states clearly.
- Disabled State:
- Buttons marked as
disabledprevent all interactions while remaining visually distinguishable.
- Buttons marked as
Conclusion
The Button component is a highly flexible and accessible solution for modern interfaces. With its wide range of variants, sizes, and animations, it provides developers with the tools they need to build engaging, inclusive, and user-friendly applications. Its focus on performance and customizability makes it a cornerstone for UI design.