Button

Displays a button or a component that looks like a button.

Installation

<!-- alp-ui.js MUST come before Alpine.js -->
<script defer src="https://cdn.jsdelivr.net/gh/novaspand/alp-ui/dist/alp-ui.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>

Usage

<!-- Pass variant and size as props -->
<button x-data="button({ variant: 'default', size: 'default' })" x-bind="buttonAttrs">
  Button
</button>

<!-- Outline variant, large size -->
<button x-data="button({ variant: 'outline', size: 'lg' })" x-bind="buttonAttrs">
  Large Outline
</button>

Examples

Size

Use different size classes to change the button size.

Default

Secondary

Destructive

Outline

Ghost

Link

Icon

With Icon

Rounded

Add rounded-full to the element or use class prop.

Loading

Toggle a loading state with a spinner icon.

Disabled

Rounded

Use rounded: true for pill-shaped buttons.

API Reference

Prop Type Default
variant "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" "default"
size "xs" | "sm" | "default" | "lg" | "icon" | "icon-sm" | "icon-lg" "default"
rounded boolean false