robsontenorio/mary
MaryUI brings gorgeous daisyUI + Tailwind components to Laravel Livewire. Build modern dashboards and apps faster with ready-to-use UI elements, great defaults, and solid docs at mary-ui.com.
## Getting Started
### Minimal Setup
1. **Installation**:
```bash
composer require robsontenorio/mary
For Tailwind CSS integration (default):
npm install -D daisyui
Add to tailwind.config.js:
plugins: [require("daisyui")],
daisyui: { themes: ["light", "dark"] }
Publish Assets (if not using default Tailwind setup):
php artisan mary:install
First Use Case:
<livewire:mary-button label="Click Me" />
Renders a pre-styled button with Livewire reactivity.
<livewire:mary-input
name="email"
label="Email Address"
type="email"
:rules="['required', 'email']"
/>
<mary-card>
<mary-card-header>Title</mary-card-header>
<mary-card-body>Content</mary-card-body>
</mary-card>
<livewire:mary-form>
<mary-input name="username" :rules="['required']" />
{{ $errors->mary('username') }} <!-- Auto-renders error messages -->
</livewire:mary-form>
mary-tabs with Livewire’s wire:model.live for real-time validation.<livewire:mary-table
:items="$users"
:columns="[
['label' => 'Name', 'property' => 'name'],
['label' => 'Email', 'property' => 'email', 'sortable' => true],
]"
/>
<livewire:mary-table
:items="$orders"
expandable
:expandable-content="fn($order) => view('orders.detail', ['order' => $order])"
/>
<mary-drawer wire:model="showDrawer">
<mary-drawer-header>Settings</mary-drawer-header>
<mary-drawer-body>
<livewire:user-settings />
</mary-drawer-body>
</mary-drawer>
<livewire:mary-spotlight
:items="$searchResults"
property="name"
wire:model="searchQuery"
/>
<livewire:mary-calendar
wire:model="selectedDate"
:events="$events"
/>
<mary-badge value="3" />
<!-- Now correctly handles value logic (fixed in 2.8.3) -->
Tailwind Customization:
Extend DaisyUI themes in tailwind.config.js:
daisyui: {
themes: [
{
mytheme: {
"primary": "#3b82f6",
"secondary": "#10b981",
}
}
]
}
Livewire Hooks:
Use wire:ignore for non-reactive elements:
<div wire:ignore>
<mary-toast id="success-toast" />
</div>
Asset Optimization:
php artisan mary:install --no-css
<div x-data="{ show: false }" @click.away="show = false">
<button @click="show = !show">Toggle</button>
<mary-dropdown x-show="show">...</mary-dropdown>
</div>
RTL Support:
me-* instead of mr-*).dir="rtl" to <html> and ensure logical properties are used:
<mary-button class="me-4"> <!-- Right margin in LTR, left in RTL --> </mary-button>
Livewire 4 Migration:
mary-calendar may need CDN updates (e.g., VanillaCalendarPro v3).resources/views/components/mary/calendar.blade.php:
<script src="https://cdn.jsdelivr.net/npm/vanilla-calendar-pro@3.1.0/index.min.js"></script>
Currency Input:
wire:model.live.debounce.500ms for smoother updates.Table Sorting:
sort-by-property conflicts with custom column names.sort-by="custom_method" and define the method in your Livewire component:
public function custom_method($query, $direction) {
return $query->orderBy('custom_column', $direction);
}
Drawer Backdrop:
without-backdrop-close or handle wire:click.away manually.Badge Component:
value prop is passed as a string:
<mary-badge :value="'3'" /> <!-- Explicit string for clarity -->
Choices.js (Select2 Alternative):
choices.js is loaded after Livewire’s Alpine.js.Component Props:
Use {{ dd($this->props) }} in Livewire components to inspect passed attributes.
Tailwind Conflicts:
!important sparingly; prefer utility classes like !rounded-none.Livewire Events:
wire:model or wire:key attributes.Asset Loading:
mary:install ran and assets are published to public/build.RTL Debugging:
mr-*, ml-*) with logical ones (me-*, ms-*) in 2.8.3+.Custom Components:
Extend existing components by copying from resources/views/components/mary/ and modifying:
@props(['customProp' => 'default'])
<div x-data="{ open: false }">
{{ $slot }}
<div x-show="open" @click.away="open = false">
{{ $customProp }}
</div>
</div>
Theme Overrides:
Override DaisyUI variables in tailwind.config.js:
theme: {
extend: {
colors: {
primary: '#7dd3fc',
}
}
}
Alpine.js Integration:
Use x-init for dynamic behavior:
<mary-collapse x-data="{ open: true }" x-init="setTimeout(() => open = false, 3000)">
Content
</mary-collapse>
Localization: Override default labels (e.g., "Cancel") in your Livewire component:
public function mount() {
$this->labels = [
'cancel' => __('buttons.cancel'),
];
}
Testing: Use Livewire’s testing helpers
How can I help you explore Laravel packages today?