GitHub Stars

Button

Displays a button or a component that looks like a button.

Installation

npx shadcn@latest add @fulldev/button

Usage

import { Button } from "@/components/ui/button"

You can also import buttonVariants to reuse button styles on custom elements.

import { buttonVariants } from "@/components/ui/button"
<Button>Button</Button>

Use the polymorphic as prop with href to render the button as a link element.

---
import { Button } from "@/components/ui/button"
---

<Button as="a" href="/login">Login</Button>

Polymorphic

Button is polymorphic via as. Pass as to change the rendered element and use the relevant attributes for that element.

<Button as="button" type="button">Save</Button>
<Button as="a" href="/docs">Docs</Button>
<Button as="label" for="file-upload">Upload</Button>

Examples

With Icon

The spacing between the icon and the text is automatically adjusted based on the size of the button. You do not need any margin on the icon.

Rounded

Use the rounded-full class to make the button rounded.

API Reference

See the GitHub source code for more information on props.