Skip to content

Button

The Button component supports multiple variants, sizes, and states.

---
import Button from '@/components/ui/Button.astro';
---
<Button>Click me</Button>
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="link">Link Style</Button>
<Button variant="destructive">Delete</Button>
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>

For buttons on dark backgrounds:

<Button colorScheme="invert">On Dark Background</Button>

Square button for icons only:

---
import Icon from '@/components/ui/Icon.astro';
---
<Button icon size="sm">
<Icon name="search" />
</Button>
<!-- Loading state -->
<Button loading>Submitting...</Button>
<!-- Disabled state -->
<Button disabled>Disabled</Button>
<!-- Full width -->
<Button fullWidth>Full Width Button</Button>

Renders as an anchor tag when href is provided:

<Button href="/about">Go to About</Button>
<Button href="/signup" variant="primary" size="lg">Sign Up</Button>
PropTypeDefaultDescription
variant'primary' | 'secondary' | 'outline' | 'ghost' | 'link' | 'destructive''primary'Visual style
size'sm' | 'md' | 'lg''md'Button size
colorScheme'default' | 'invert''default'Color scheme
iconbooleanfalseIcon-only mode (square)
loadingbooleanfalseShow loading spinner
fullWidthbooleanfalseFull container width
hrefstringRenders as <a>
disabledbooleanfalseDisable interaction
type'button' | 'submit' | 'reset''button'Button type
  • Uses native <button> or <a> elements
  • Proper focus states
  • Disabled state prevents interaction
  • Loading state announces to screen readers
<form>
<Input label="Email" name="email" type="email" />
<Button type="submit" fullWidth>Subscribe</Button>
</form>
<div class="flex gap-2">
<Button variant="outline">Cancel</Button>
<Button variant="primary">Save Changes</Button>
</div>
<section class="bg-surface-invert py-16">
<Button colorScheme="invert" size="lg">Get Started</Button>
</section>