mrshanebarron / radio-group
Styled radio button groups for Laravel. Supports Livewire and Blade.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Vue
pkg:composer/mrshanebarron/radio-group
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
This package is auto-updated.
Last update: 2025-12-14 02:28:00 UTC
README
Styled radio button groups. Built for Laravel with support for Livewire, Blade, and Alpine.js.
Installation
composer require mrshanebarron/radio-group
The service provider will be auto-discovered. If you need to register it manually:
// config/app.php 'providers' => [ // ... MrShaneBarron\RadioGroup\RadioGroupServiceProvider::class, ];
Usage
Livewire Component
<livewire:ld-radio-group />
Blade Component
<x-ld-radio-group />
With Props
<x-ld-radio-group :options="[]" value=null :inline="false" :disabled="false" />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options |
array | [] |
Radio options with 'value', 'label' |
value |
string | null |
Selected value |
inline |
boolean | false |
Display options inline |
disabled |
boolean | false |
Disable all options |
Configuration
Publish the config file:
php artisan vendor:publish --tag=ld-radio-group-config
This will create a config/ld-radio-group.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-radio-group-views
Views will be published to resources/views/vendor/ld-radio-group/.
Styling
The component uses Tailwind CSS classes by default. You can customize styles by:
- Publishing views and modifying the Blade templates
- Using the
classattribute to add custom classes - Overriding default styles in your CSS
<x-ld-radio-group class="custom-class" />
Events
The component dispatches Livewire events you can listen to:
| Event | Payload | Description |
|---|---|---|
radio-group:updated |
Component data | Fired when state changes |
radio-group:initialized |
Initial data | Fired on component mount |
// In your Livewire component protected $listeners = ['radio-group: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-radio-group 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.