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
, andexpandIcon
for enhanced interactivity.
- Includes unique hover effects like
- Multiple Sizes:
- Available in
small
,default
,large
, andicon
sizes 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
asChild
prop 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
default
orshine
for primary actions such as signing up or submitting forms.
- Use prominent buttons like
- Destructive Actions:
- Highlight critical actions such as deletions with the
destructive
variant.
- Highlight critical actions such as deletions with the
- Secondary Actions:
- Pair primary buttons with subtle options like
secondary
for less prominent actions.
- Pair primary buttons with subtle options like
- Toolbars and Icon Buttons:
- Use the
icon
size for compact buttons in toolbars or quick actions.
- Use the
- Dynamic UIs:
- Enhance user interfaces with interactive effects like
ringHover
orexpandIcon
.
- 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-expanded
for screen readers.
- Supports attributes like
- Keyboard Navigation:
- Fully operable using
Tab
andEnter
keys.
- Fully operable using
- Focus Management:
- Includes focus-visible styles to indicate active states clearly.
- Disabled State:
- Buttons marked as
disabled
prevent 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.