Button
Buttons allow users to perform actions or navigate with a single click.
Installation
Add the button component to your project:
Usage
Primary Button
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Secondary Button
Button
secondaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Destructive Button
Button
destructiveLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Outline Button
Button
outlineLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Ghost Button
Button
ghostLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Sizes
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
With Icon
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Loading State
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Disabled
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Pill Shape
Button
primaryLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Icon Button
Button
ghostLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Button
Full preview from the registry iframe.
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string |
primary |
Button style variant |
size |
string |
md |
Button size (xs, sm, md, lg, xl) |
type |
string |
button |
Button type (button, submit, reset) |
disabled |
boolean |
false |
Disable the button |
loading |
boolean |
false |
Show loading spinner |
icon |
string |
null |
Icon name (left side) |
iconRight |
string |
null |
Icon name (right side) |
iconOnly |
boolean |
false |
Icon-only button |
pill |
boolean |
false |
Rounded pill shape |
block |
boolean |
false |
Full width button |
href |
string |
null |
URL for link buttons |
action |
string |
null |
Livewire action to target |
Variants
default- Default stylingprimary- Primary action buttonsecondary- Secondary action buttonoutline- Outlined buttonghost- Minimal styling, hover onlydestructive- Dangerous action (delete, remove)
Sizes
sm- Small buttondefault- Default sizelg- Large buttonicon- Square button for icons
Examples
Submit Form
<form method="POST" action="/submit">
@csrf
<x-button type="submit">Submit</x-button>
</form>
Link Button
<a href="{{ route('dashboard') }}">
<x-button>Go to Dashboard</x-button>
</a>
Disabled State
<x-button disabled>
Disabled
</x-button>
Full Width
<x-button class="w-full">
Full Width Button
</x-button>
Customization
The button component uses Tailwind CSS classes. You can customize the appearance by modifying the component in your project:
@
@props([
'variant' => 'primary',
'size' => 'md',
// ... other props
])
@php
$variantClasses = match($variant) {
'primary' => 'bg-primary text-primary-foreground hover:bg-primary/90',
'secondary' => 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
// ... customize variants here
};
@endphp
<button {{ $attributes->class([$variantClasses]) }}>
{{ $slot }}
</button>
Accessibility
Buttons include proper ARIA attributes and keyboard support:
- Tab - Focus button
- Enter/Space - Activate button
- Disabled state - Automatically applied
Next Steps
- Explore Card component
- Learn about Input component
- View Dialog component