Basic Buttons
A simple, customizable button component with support for variants, sizes, and states like hover and disabled — perfect for any UI.
Variant
Defines the style variant of the component. It can be used to apply different visual styles like primary, chai, sky, etc.
Size
Adjusts the size of the component. Possible values are sdot, m, xl, allowing you to control the component's size to fit various design requirements.
Rounded
Determines if the component should have rounded corners.
Hover
Enables hover effects on the component. You can customize the hover state to define interactions when the component is hovered over.
Disabled
When set to true, this prop disables the component, preventing user interaction and visually indicating its inactive state.
CLI Installation
Before proceeding, ensure that ShadCN UI is properly installed in your project.
You can refer to the installation guide for detailed instructions.
Once ShadCN is set up, you can install the component using the CLI:
Manual Installation
To manually set up the Button component in your project, follow the steps below:
- Navigate to the
srcdirectory in your project. - Create a new folder named
components. - Inside the
componentsfolder, create a subfolder namedui. - Within
components/ui, create a new file calledbasicButton.tsx. - Copy and paste the provided button component code into this file.
Once added, you can import and use the component throughout your application.
Usage
To use the Button component in your project, follow the steps below:
Import the component
Use the component
Props
The Button component accepts the following props to customize its appearance and behavior:
| Prop | Type | Description | Accepted Values |
|---|---|---|---|
variant | string | Defines the button's color theme. | "destructive", "primary", "yellow", "chai", "lavender", "purple", "teal", "green", "sky", "blue", "facebook", "stroke" |
size | string | Sets the button size. | "sdot", "dot", "sm", "m", "xl" |
rounded | string | Controls the border-radius shape. | "circle", "medium", "low", "rectangle", "small" |
hover | string | Sets the hover interaction effect. | "float", "rotate", "slide",shadow, "ring" |
hover | string | Sets the hover interaction effect. | "float", "rotate", "slide",shadow, "ring" |
className | string | custom className effects | className="string", |