williamalmeida/mary-v1-community
Installation
composer require williamalmeida/mary-v1-community
Add Tailwind CSS and DaisyUI to your tailwind.config.js:
module.exports = {
plugins: [
require('daisyui'),
require('mary-v1-community'),
],
daisyui: {
themes: ["light", "dark", "cupcake"], // Include your preferred themes
},
}
Publish Assets
npm run dev // or `npm run build` for production
First Use Case Use a pre-built component in a Livewire blade:
<x-mary-button type="primary" wire:click="submitForm">
Submit
</x-mary-button>
Verify the component renders correctly in your Livewire component.
Component Integration
<x-mary-{component}> tags (e.g., <x-mary-card>) in Livewire blades.type, size, or wire:model directly:
<x-mary-input wire:model="name" placeholder="Enter name" type="text" />
<x-mary-modal>
<x-slot name="title">Confirm Action</x-slot>
<p>Are you sure?</p>
</x-mary-modal>
Theming
tailwind.config.js:
daisyui: {
themes: [
{
mytheme: {
"primary": "#3b82f6",
"secondary": "#10b981",
},
},
],
}
<x-mary-button theme="mytheme">Custom Themed</x-mary-button>
Livewire + Mary Integration
<x-mary-select wire:model="selectedOption">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</x-mary-select>
wire:click or wire:change for interactivity:
<x-mary-checkbox wire:click="toggleFeature({{ $feature->id }})">
Enable Feature
</x-mary-checkbox>
Layout Patterns
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<x-mary-card>...</x-mary-card>
<x-mary-card>...</x-mary-card>
</div>
<x-mary-form wire:submit.prevent="save">
<x-mary-input wire:model="name" />
<x-mary-button type="submit">Save</x-mary-button>
</x-mary-form>
Component Registration
config/view.php:
'components' => [
'mary' => App\View\Composers\MaryComposer::class,
],
php artisan view:clear if components fail to load.Tailwind/DaisyUI Conflicts
tailwind.config.js:
plugins: [
require('tailwindcss'),
require('daisyui'),
require('mary-v1-community'), // Load last
],
Livewire + Mary Styling
resources/css/app.css:
@layer components {
@import 'mary-v1-community/dist/mary.css';
}
Dynamic Theming
document.querySelectorAll('[data-theme]').forEach(el => {
el.addEventListener('click', () => {
document.documentElement.setAttribute('data-theme', el.dataset.theme);
});
});
Inspect Components Use browser dev tools to verify classes are applied:
<!-- Check for missing classes -->
<x-mary-button class="debug">Hover</x-mary-button>
Add debug class to inspect rendered HTML/CSS.
Livewire Debugging
public function mount() {
$this->log('Component mounted', 'debug');
}
storage/logs/laravel.log) for errors.Dependency Conflicts
!important sparingly or scope Mary’s CSS:
.mary-component {
@apply /* Tailwind classes */;
}
Custom Components
Extend existing components by copying from resources/views/components/mary/ and modifying:
<!-- Example: Custom Alert -->
<x-mary-alert type="info" :show="$showAlert">
{{ $message }}
</x-mary-alert>
Dark Mode Leverage DaisyUI’s dark mode:
<x-mary-toggle wire:click="toggleDarkMode" />
Toggle via Livewire:
public $darkMode = false;
public function toggleDarkMode() {
$this->darkMode = !$this->darkMode;
$this->dispatch('theme-updated', data: ['dark' => $this->darkMode]);
}
Accessibility Add ARIA attributes to components:
<x-mary-button aria-label="Submit form" wire:click="submit">
Submit
</x-mary-button>
Localization
Use Blade’s @lang directive for multi-language support:
<x-mary-button>{{ __('mary.submit') }}</x-mary-button>
How can I help you explore Laravel packages today?