Button
Form Controlsimport { Button } from "bits-ui" Action variants
One behavioral primitive, styled for primary, secondary, destructive and disabled states
Choose an action
<script lang="ts">
import { Button } from 'bits-ui';
import { Check, Download, Trash2 } from '@lucide/svelte';
let action = $state('Choose an action');
</script>
<div class="space-y-5">
<div class="flex flex-wrap items-center gap-3">
<Button.Root class="btn btn-primary gap-2" onclick={() => (action = 'Changes saved')}>
<Check class="size-4" /> Save changes
</Button.Root>
<Button.Root class="btn gap-2 border border-ink-700 bg-ink-850 hover:bg-ink-800" onclick={() => (action = 'Report downloaded')}>
<Download class="size-4" /> Download report
</Button.Root>
<Button.Root class="btn btn-ghost gap-2 text-accent-500" onclick={() => (action = 'Draft deleted')}>
<Trash2 class="size-4" /> Delete draft
</Button.Root>
<Button.Root class="btn btn-primary" disabled>Publishing…</Button.Root>
</div>
<p class="text-sm text-ink-400" aria-live="polite">{action}</p>
</div>
Links as buttons
Adding href changes the underlying element from button to anchor
Navigation action
Passing href makes the root render an anchor while retaining the button skin.
Explore CommandExternal destination
Standard anchor attributes pass through to the rendered element.
Local Button guide<script lang="ts">
import { Button } from 'bits-ui';
import { ArrowRight, ExternalLink } from '@lucide/svelte';
</script>
<div class="grid gap-4 sm:grid-cols-2">
<div class="card p-4">
<p class="mb-1 text-sm font-medium text-ink-50">Navigation action</p>
<p class="mb-4 text-xs text-ink-400">Passing href makes the root render an anchor while retaining the button skin.</p>
<Button.Root href="/components/command" class="btn btn-primary gap-2">
Explore Command <ArrowRight class="size-4" />
</Button.Root>
</div>
<div class="card p-4">
<p class="mb-1 text-sm font-medium text-ink-50">External destination</p>
<p class="mb-4 text-xs text-ink-400">Standard anchor attributes pass through to the rendered element.</p>
<Button.Root
href="https://wiki.bits.loca.zone/components/button"
target="_blank"
rel="noreferrer"
class="btn gap-2 border border-ink-700 bg-ink-850 hover:bg-ink-800"
>
Local Button guide <ExternalLink class="size-4" />
</Button.Root>
</div>
</div>
Button.Root chooses its element from its props: without href it is a button, while supplying href renders an anchor for real navigation semantics. Use the link form for destinations, not merely to make an action look like a link.
The disabled prop prevents interaction and defaults to false. Every root exposes data-button-root, giving every visual variant a stable styling hook without duplicating behavior.