Triggers an action, or renders an anchor when given an href. Styled with theme tokens and shadcn variant names.
<script lang="ts">
import { Button } from "#lib/components/ui/button/index.js";
</script>
<Button>Button</Button>pnx remote0 add https://plainsv.com/r/button.jsonSet variant to default, secondary, outline, ghost, destructive, link, or bare. The default is default, and bare drops the background, border, and padding so the content is the whole button.
<Button>Default</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Destructive</Button>
<Button variant="link">Link</Button>
<Button variant="bare">Bare</Button>Set size to xs, sm, md, or lg. The default is md, and the corner radius follows the size.
<Button size="xs">Size xs</Button>
<Button size="sm">Size sm</Button>
<Button size="md">Size md</Button>
<Button size="lg">Size lg</Button>Place an icon before or after the text and the padding tightens to fit. For icon-only buttons, use the square sizes icon-xs, icon-sm, icon-md, and icon-lg, and add an aria-label. With variant="bare", the square shrinks 8 pixels below the control height and the icon fills it with no padding, so icon-xs, icon-sm, icon-md, and icon-lg show 16, 24, 28, and 32 pixel icons for inline actions such as copy or close. Bare buttons take the surrounding text color, dim on hover, and show a thin --ring outline instead of the focus ring.
<script lang="ts">
import { Button } from "#lib/components/ui/button/index.js";
import { ArrowRightIcon, MailIcon, PlusIcon, XIcon } from "@lucide/svelte";
</script>
<Button><MailIcon />Login with email</Button>
<Button variant="outline">Continue<ArrowRightIcon /></Button>
<Button size="icon-md" variant="outline" aria-label="Add"><PlusIcon /></Button>
<Button size="icon-sm" variant="bare" aria-label="Close"><XIcon /></Button>Set rounded to xs through 4xl or pill to override the radius from the size.
<Button variant="secondary" rounded="sm">Rounded sm</Button>
<Button variant="secondary" rounded="pill">Rounded pill</Button>
<Button size="icon-md" rounded="pill" aria-label="Add"><PlusIcon /></Button>Pass href to render an anchor with the same styles. A disabled link drops its href, sets aria-disabled, and leaves the tab order.
<Button href="/docs/components">Browse components</Button>
<Button href="/docs/components" variant="link">Text link</Button>
<Button href="/docs/components" variant="outline" disabled>Disabled link</Button>Set disabled to dim the button and block clicks. Set aria-invalid="true" to show the invalid ring, such as for a form submit that failed validation.
<Button disabled>Disabled</Button>
<Button variant="outline" aria-invalid="true">Invalid</Button>The Button props extend the native button attributes, or the a attributes when href is set. Extra attributes and event handlers such as onclick pass through to the element.
interface ButtonBaseProps {
/** Corner radius; follows `size` when omitted */
rounded?: UiRounded;
/** Visual style of the button; `bare` drops the background, border, and padding, and its icon fills an `icon-*` size */
variant?: "default" | "outline" | "secondary" | "destructive" | "ghost" | "link" | "bare";
/** Size on the shared scale, or a square `icon-*` size for icon-only buttons */
size?: UiSize | `icon-${UiSize}`;
}