Button

An interactive element that triggers an action when clicked, supporting various visual styles and states.

Anatomy

<script>
  import { Button } from "@saas-ui/svelte/components/button";
</script>

<!-- Basic button -->
<Button>Click me</Button>

<!-- Button with icon -->
<Button>
  <Icon slot="start" />
  With Icon
</Button>

<!-- Button group -->
<Button.Group>
  <Button>One</Button>
  <Button>Two</Button>
  <Button>Three</Button>
</Button.Group>

Examples

Basic Accessibility

Basic button with default styling for general actions.

Colours Accessibility

Use the colour prop to change the colour scheme. Supports all standard colour palettes.

Group Accessibility

Use Button.Group to group related buttons together with connected styling.

Loading Accessibility

Use the loading and loadingText props to show a loading spinner during async operations.

Sizes Accessibility

Use the size prop to change the size of the button. Available sizes: xs, sm, md, lg, xl.

Variants Accessibility

Use the variant prop to change the visual style. Available variants: solid, subtle, outline, ghost, plain, surface, glass.

With Icon Accessibility

Add icons to buttons by including them as children. Use icon-only buttons for compact actions.

Props

Prop Type Default Description
variant solid | subtle | outline | ghost | plain | surface | glass surface The visual style of the button
size xs | sm | md | lg | xl md The size of the button
colour gray | red | orange | yellow | green | teal | blue | cyan | purple | pink | rose gray The colour scheme of the button
loading boolean false Whether the button is in a loading state
loadingText text - Text to display when loading
disabled boolean false Whether the button is disabled