Skip to content
X

Button

---
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
---
<Button variant="outline">Button</Button>
<Button variant="outline" size="icon" aria-label="Submit">
<Icon name="arrow-up-right" />
</Button>

To install the button component, run the following command:

Terminal window
npx shadcn@latest add @fulldev/button
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>

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>
---
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
---
<Button variant="outline" size="sm">Small</Button>
<Button variant="outline" size="icon-sm">
<Icon name="arrow-up-right" />
</Button>
<Button variant="outline">Default</Button>
<Button variant="outline" size="icon">
<Icon name="arrow-up-right" />
</Button>
<Button variant="outline" size="lg">Large</Button>
<Button variant="outline" size="icon-lg">
<Icon name="arrow-up-right" />
</Button>
---
import { Button } from "@/components/ui/button"
---
<Button>Button</Button>
---
import { Button } from "@/components/ui/button"
---
<Button variant="outline">Outline</Button>
---
import { Button } from "@/components/ui/button"
---
<Button variant="secondary">Secondary</Button>
---
import { Button } from "@/components/ui/button"
---
<Button variant="ghost">Ghost</Button>
---
import { Button } from "@/components/ui/button"
---
<Button variant="destructive">Destructive</Button>
---
import { Button } from "@/components/ui/button"
---
<Button variant="link">Link</Button>
---
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
---
<Button variant="outline" size="icon" aria-label="Submit">
<Icon name="circle-fading-arrow-up" />
</Button>

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.

---
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
---
<Button variant="outline" size="sm">
<Icon name="git-branch" />
New branch
</Button>

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

---
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
---
<Button class="rounded-full" size="icon" variant="outline">
<Icon name="arrow-up" />
</Button>
---
import { Button } from "@/components/ui/button"
import { Spinner } from "@/components/ui/spinner"
---
<Button size="sm" variant="outline" disabled>
<Spinner />
Submit
</Button>