<x-widget.button>
Button Blade component for Laravel and Livewire
Button or link in primary, secondary, tertiary, danger, neutral and link variants, with sizes, icons, icon-only buttons and a loading state. Guards forms against double submits. Includes a back link. Works inside Livewire components, wire:submit forms included.
php artisan bladewell:add button
- Also adds
- Icon
- Used by
- Calendar, Clock, Date range picker, Dropdown, Image cropper, Kanban, Modal, Pagination, Popover, Repeater, Sortable list, Table
- Works with
- Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
- Guides
- Build a Laravel form from your validation rules · Editable table cells in Laravel with Livewire · A Livewire modal that stays open through re-renders · Using Blade components in Livewire 3 and 4 · Two-factor authentication screens for Laravel Fortify · Passkey sign-in for Laravel with Fortify · Real-time notification bell with Laravel Reverb · AI agent actions with Approve and Deny in Laravel · Laravel AI chat with Livewire and streaming replies · Livewire multi-step form with validation per step · Toast notifications in Laravel and Livewire · Livewire file upload with progress and drag and drop · Laravel searchable select that loads from the database · Laravel Blade card, avatar and empty state patterns
Usage
In a form
A submit button guards against double submits: once its form submits, it shows its loading state until the next page arrives.
<form method="POST" action="{{ route('profile.update') }}">
@csrf
{{-- your fields --}}
<x-widget.button type="submit">Save changes</x-widget.button>
{{-- Opt out where the page stays open after submitting, such as a file download. --}}
<x-widget.button type="submit" formaction="{{ route('profile.export') }}" :submit-guard="false" variant="neutral">Export CSV</x-widget.button>
</form>
{{-- confirm asks first, and only a yes submits. With the modal widget installed it asks in the modal's dialog, in red for a danger button; without it, in the browser's own. --}}
<form method="POST" action="{{ route('orders.destroy', $order) }}">
@csrf
@method('DELETE')
<x-widget.button type="submit" variant="danger" :confirm="'Delete order #'.$order->number.'?'" confirm-message="The order and its invoice are removed for good.">Delete order</x-widget.button>
</form>
Livewire
In a wire:submit form, Livewire sends the form itself and holds the submit button until the answer comes back: the button shows its loading state meanwhile, keeps its colour, and gets focus back afterwards if it had it. A wire:click button shows it with wire:loading.attr="aria-busy" (and wire:target, so other requests don't set it off); a quick toggle is better without. :loading set from a property works too. confirm="…" asks before wire:click runs, which then only ever sees a confirmed click.
<form wire:submit="save" class="space-y-5">
{{-- your fields --}}
<x-widget.button type="submit">Save changes</x-widget.button>
</form>
<x-widget.button variant="neutral" wire:click="export" wire:loading.attr="aria-busy" wire:target="export">Export CSV</x-widget.button>
<x-widget.button variant="danger" :loading="$deleting" wire:click="delete">Delete</x-widget.button>
Examples
Variants
danger is for destructive actions; neutral is the quiet choice next to a primary one, like Cancel beside Save.
Show code Hide code
<div class="flex flex-wrap items-center gap-3">
<x-widget.button>Primary</x-widget.button>
<x-widget.button variant="secondary">Secondary</x-widget.button>
<x-widget.button variant="tertiary">Tertiary</x-widget.button>
<x-widget.button variant="danger">Delete</x-widget.button>
<x-widget.button variant="neutral">Cancel</x-widget.button>
<x-widget.button variant="link">Link</x-widget.button>
</div>
Sizes and states
With href the button renders as a link. Loading and disabled both block clicks; while loading, the spinner takes the icon's place.
Show code Hide code
<div class="flex flex-wrap items-center gap-3">
<x-widget.button size="sm">Small</x-widget.button>
<x-widget.button size="lg">Large</x-widget.button>
<x-widget.button icon-start="plus">Add wallet</x-widget.button>
<x-widget.button variant="secondary" icon-start="check" loading>Saving</x-widget.button>
<x-widget.button variant="secondary" disabled>Disabled</x-widget.button>
<x-widget.button variant="tertiary" href="#" icon-end="arrow-right">Continue</x-widget.button>
</div>
Icon only
icon with no text makes a square button. label is required: it is the button's name for screen readers, and its tooltip.
Show code Hide code
<div class="flex flex-wrap items-center gap-3">
<x-widget.button icon="plus" label="Add wallet" />
<x-widget.button icon="search" label="Search" variant="secondary" />
<x-widget.button icon="x" label="Close" variant="neutral" />
<x-widget.button icon="eye" label="Show details" variant="tertiary" size="sm" />
<x-widget.button icon="refresh-cw" label="Refresh" variant="neutral" size="lg" />
</div>
Back
Show code Hide code
<x-widget.button.back label="Back to wallets" href="#" />
Props
Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.
<x-widget.button>
| Prop | Default | Description |
|---|---|---|
| variant |
'primary'
|
primary, secondary, tertiary (outlined), danger (destructive actions), neutral (the quiet choice, e.g. Cancel beside Save) or link (looks like a text link). |
| size |
'md'
|
sm, md or lg. |
| type |
'button'
|
The button's type: button, submit or reset. Ignored with href. |
| href |
null
|
Makes it a link to this URL. While disabled or loading it renders as a disabled button instead. |
| loading |
false
|
Busy: a spinner takes the place of the first icon and it can't be pressed. Screen readers hear "Loading". |
| disabled |
false
|
Greyed out: it can't be pressed. |
| icon-start |
null
|
An icon before the text. |
| icon-end |
null
|
An icon after the text. |
| icon |
null
|
An icon-only, square button: shows just this icon, and needs a label. |
| label |
null
|
With icon: the button's name for screen readers and its tooltip. Required there. |
| submit-guard |
true
|
type="submit": once its form submits, the button shows as loading so the form can't be sent twice. false turns it off. |
| confirm |
null
|
A question, e.g. "Delete this order?": asked first, and the button only acts (submits, follows its link, runs wire:click) once it's confirmed. In the modal's dialog when the app has the modal widget, otherwise the browser's. |
| confirm-message |
null
|
With confirm: more text under the question. |
| confirm-label |
null
|
With confirm: the confirm button's text. Defaults to the button's own text. |
| confirm-cancel |
null
|
With confirm: the cancel button's text. Defaults to "Cancel". |
<x-widget.button.back>
| Prop | Default | Description |
|---|---|---|
| href |
null
|
Where it goes. Defaults to the previous page. |
| label |
null
|
Text beside the arrow. Without it, just the arrow shows, named "Back" for screen readers. |
Accessibility
All 4 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.
Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.
Source
What bladewell:add button writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from
the components it also adds , and the theme and base CSS.
resources/views/components/widget/button/back.blade.php Show
resources/views/components/widget/button/index.blade.php Show
resources/js/widget/button/index.js Show