mirror of
https://github.com/huntabyte/shadcn-svelte.git
synced 2026-09-14 19:33:46 +08:00
d9ca0fbfea
Co-authored-by: Braden Wong <git@bradenwong.com>
2.6 KiB
2.6 KiB
title, description, component, links
| title | description | component | links |
|---|---|---|---|
| Button | Displays a button or a component that looks like a button. | true |
Installation
{#snippet cli()} {/snippet} {#snippet manual()}Copy and paste the component source files linked at the top of this page into your project.
{/snippet}Usage
<script lang="ts">
import { Button } from "$lib/components/ui/button/index.js";
</script>
<Button variant="outline">Button</Button>
Link
You can convert the <button> into an <a> element by simply passing an href as a prop.
<script lang="ts">
import { Button } from "$lib/components/ui/button/index.js";
</script>
<Button href="/dashboard">Dashboard</Button>
Alternatively, you can use the buttonVariants helper to create a link that looks like a button.
<script lang="ts">
import { buttonVariants } from "$lib/components/ui/button";
</script>
<a href="/dashboard" class={buttonVariants({ variant: "outline" })}>
Dashboard
</a>
Examples
Primary
Secondary
Destructive
Outline
Ghost
Link
With Icon
Icon
Loading
Use the Spinner component to indicate a loading state.