Button

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

Demo

The variant says how much the action asks to be pressed. default is the one action a view is for, secondary and outline are the ones beside it, ghost is for actions in a toolbar or a row that should not draw the eye, and destructive is for one that cannot be undone.

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

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

Size

Use the size prop to change the size of the button.

Dark previewReplay previewOpen in new tab

Default

Dark previewReplay previewOpen in new tab

Secondary

Dark previewReplay previewOpen in new tab

Outline

Dark previewReplay previewOpen in new tab

Ghost

Dark previewReplay previewOpen in new tab

Destructive

Dark previewReplay previewOpen in new tab

Outline Destructive

An outline button that reads as destructive. Use it when the action is dangerous but not the primary one on screen.

Dark previewReplay previewOpen in new tab

Icon

Dark previewReplay previewOpen in new tab

With Icon

Remember to add the data-icon inline-start or inline-end attribute to the icon for the correct spacing.

Dark previewReplay previewOpen in new tab

Pill

shape="pill" rounds the ends fully at any size, icon-only buttons included.

Dark previewReplay previewOpen in new tab

Spinner

Render a Spinner component inside the button to show a loading state.

Dark previewReplay previewOpen in new tab

Button Group

Wrap buttons in ButtonGroup to join them into a single control.

Dark previewReplay previewOpen in new tab

API Reference

Button

PropTypeDefaultDescription
variant"default" | "secondary" | "outline" | "outline-destructive" | "destructive" | "ghost" | "link""default"Visual style.
size"xs" | "sm" | "default" | "lg" | "xl" | "icon" | "iconXs" | "iconSm" | "iconLg""default"Height and padding: sm 32px, default 36px (the height of an Input or a Select, so they line up in one row), lg 44px. xl is one step above lg, for hero and landing CTAs; it has no icon-only counterpart. Icon sizes are square and also accept the kebab aliases icon-xs, icon-sm, and icon-lg.
shape"default" | "pill""default"pill rounds the ends fully, whatever the size. Use it instead of a rounded-full class.
loadingbooleanfalseShows a spinner over the label and disables the button. The label stays in place, hidden, so the width does not change.
tostring—Renders as NuxtLink when set. External URLs (http) open in a new tab.
asstring"button"HTML element to render when to is empty.
asChildbooleanfalseRender the child slot without a wrapper element.
classstring—Extra classes, merged with cn().
SlotDescription
defaultButton label and icons.