--- title: Button description: Displays a button or a component that looks like a button. featured: true component: true --- ## Installation CLI Manual ```bash npx shadcn@latest add button ``` Install the following dependencies: ```bash npm install @radix-ui/react-slot ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Button } from "@/components/ui/button" ``` ```tsx ``` ## Link You can use the `buttonVariants` helper to create a link that looks like a button. ```tsx import { buttonVariants } from "@/components/ui/button" ``` ```tsx Click here ``` Alternatively, you can set the `asChild` parameter and nest the link component. ```tsx ``` ## Examples ### Primary ### Secondary ### Destructive ### Outline ### Ghost ### Link ### Icon ### With Icon ### Loading ### As Child ## Changelog ### 2024-10-16 Classes for icons Added `gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0` to the button to automatically style icon inside the button. Add the following classes to the `cva` call in your `button.tsx` file. ```diff showLineNumbers title="button.tsx" const buttonVariants = cva( "inline-flex ... gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0" ) ```