coss.com Svelte

Button

A button or a component that looks like a button.

API Reference
Loading p-button-1 preview…

Installation

pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/button.json

Usage

<script lang="ts">
  import { Button } from "$lib/components/ui/button/index.js";
</script>

<Button>Button</Button>

Pass href to render a semantic link with the same styles.

<Button href="/login">Login</Button>

API Reference

Button

A button component with variant, size, and loading states. Native attributes pass to the rendered element.

PropTypeDefaultDescription
variant"default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "outline" \| "secondary""default"Controls the button styling
size"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xl" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs""default"Controls the button size
loadingbooleanfalseShows a spinner and forces disabled button behavior while loading
hrefstringRenders a semantic link with the button styles
targetstringSets the link browsing context when href is present
relstringSets the link relationship when href is present
downloadboolean \| stringDownloads the linked resource when href is present
askeyof HTMLElementTagNameMap"button"Renders a different non-link element

When loading is true, the component:

  • Renders a spinner (data-slot="button-loading-indicator")
  • Adds data-loading on the button root
  • Forces the native disabled attribute for buttons
  • Sets aria-disabled="true"
  • Preserves button width because it keeps the child content mounted and hides it visually

See the Shards Button API for keyboard and disabled behavior.

Examples

Default

Loading p-button-1 preview…

Outline

Loading p-button-2 preview…

Secondary

Loading p-button-3 preview…

Destructive

Loading p-button-4 preview…

Destructive Outline

Loading p-button-5 preview…

Ghost

Loading p-button-6 preview…
Loading p-button-7 preview…

Extra-small Size

Loading p-button-8 preview…

Small Size

Loading p-button-9 preview…

Large Size

Loading p-button-10 preview…

Extra-large Size

Loading p-button-11 preview…

Disabled

Loading p-button-12 preview…

Icon

Loading p-button-13 preview…

Icon Small Size

Loading p-button-14 preview…

Icon Large Size

Loading p-button-15 preview…

With Icon

Loading p-button-16 preview…
Loading p-button-17 preview…

Loading (Built-in Prop)

Loading p-button-41 preview…

Loading (Custom Composition)

Loading p-button-18 preview…