Styled action buttons for Laravel. Supports Livewire and Blade.

Installs: 0

Dependents: 0

Suggesters: 1

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/mrshanebarron/button

dev-main 2025-12-14 02:27 UTC

This package is auto-updated.

Last update: 2025-12-14 02:27:45 UTC


README

Styled action buttons with variants and loading states. Built for Laravel with support for Livewire, Blade, and Alpine.js.

Latest Version on Packagist Total Downloads

Installation

composer require mrshanebarron/button

The service provider will be auto-discovered. If you need to register it manually:

// config/app.php
'providers' => [
    // ...
    MrShaneBarron\Button\ButtonServiceProvider::class,
];

Usage

Livewire Component

<livewire:ld-button />

Blade Component

<x-ld-button />

With Props

<x-ld-button
    variant='primary'
    size='md'
    :loading="false"
    :disabled="false"
    icon=null
/>

Props

Prop Type Default Description
variant string 'primary' Button style variant
size string 'md' Button size
loading boolean false Show loading spinner
disabled boolean false Disable button
icon string null Icon name

Configuration

Publish the config file:

php artisan vendor:publish --tag=ld-button-config

This will create a config/ld-button.php file where you can customize default values.

Customization

Publishing Views

Customize the component appearance by publishing the views:

php artisan vendor:publish --tag=ld-button-views

Views will be published to resources/views/vendor/ld-button/.

Styling

The component uses Tailwind CSS classes by default. You can customize styles by:

  1. Publishing views and modifying the Blade templates
  2. Using the class attribute to add custom classes
  3. Overriding default styles in your CSS
<x-ld-button class="custom-class" />

Events

The component dispatches Livewire events you can listen to:

Event Payload Description
button:updated Component data Fired when state changes
button:initialized Initial data Fired on component mount
// In your Livewire component
protected $listeners = ['button:updated' => 'handleUpdate'];

public function handleUpdate($data)
{
    // Handle the update
}

Alpine.js Integration

The component works seamlessly with Alpine.js:

<div x-data="{ ' }} selected: null {{ ' }">
    <x-ld-button x-model="selected" />
    <p x-text="selected"></p>
</div>

Requirements

  • PHP 8.1+
  • Laravel 10.x, 11.x, or 12.x
  • Livewire 3.x
  • Tailwind CSS 3.x (optional, for default styling)

Testing

composer test

Changelog

Please see CHANGELOG for recent changes.

Contributing

Contributions are welcome! Please see CONTRIBUTING for details.

Security

If you discover a security vulnerability, please email shane@sbarron.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.