mahmoud-alqudsi / mavix-ui
Production-ready Blade components for Laravel 13 with Tailwind CSS v4, Alpine.js, RTL, dark mode, and accessibility support.
Package info
github.com/Mahmoud-Alqudsi/mavix-ui
Language:Blade
pkg:composer/mahmoud-alqudsi/mavix-ui
Requires
- php: ^8.3
- illuminate/console: ^13.0
- illuminate/pagination: ^13.0
- illuminate/support: ^13.0
- illuminate/view: ^13.0
Requires (Dev)
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- stamat/tailwind-merge-php: ^1.0
Suggests
- stamat/tailwind-merge-php: Resolves Tailwind CSS v4 class conflicts when passing custom classes to components (enabled automatically when installed).
Provides
None
Conflicts
None
Replaces
None
README
A collection of production-ready Blade components for Laravel 13, built with Tailwind CSS v4 and Alpine.js. Mavix UI includes RTL and dark mode support, accessible markup, localization, and components that work with Livewire.
- 33 UI components in
ui/, 16 form components informs/, and 3 layouts inlayouts/(base,guest,app) - Components work immediately after installation without publishing any files
mavix-ui:installwires the package stylesheet into your CSS entry point- Server-side toast notifications via
redirect()->toast(...)andMavixUi\Support\Toast - Built-in Arabic (
ar) and English (en) translations, configurable component prefix, and optional Tailwind v4 class conflict merging - Optional publishing for components, configuration, translations, views, auth pages, and a dashboard starter
- Tested with Pest (Orchestra Testbench), Playwright, and axe-core
Requirements
- PHP 8.3 through 8.5
- Laravel 13
- Tailwind CSS 4 (
@tailwindcss/vite) - Alpine.js 3 with
@alpinejs/focus
Installation
Install the package and run its setup command:
composer require mahmoud-alqudsi/mavix-ui php artisan mavix-ui:install
The command adds the package stylesheet import after @import "tailwindcss"; in resources/css/app.css. It also checks package.json and prints an install command if required npm packages are missing:
npm install -D tailwindcss @tailwindcss/vite npm install alpinejs @alpinejs/focus
Register Alpine's Focus plugin in resources/js/app.js before calling Alpine.start() (required for focus trapping in modals and drawers and keyboard navigation in menus):
import Alpine from 'alpinejs'; import focus from '@alpinejs/focus'; Alpine.plugin(focus); window.Alpine = Alpine; Alpine.start();
Livewire: Livewire loads and starts Alpine automatically, so do not call
Alpine.start()a second time. Register the plugin insidedocument.addEventListener('alpine:init', () => window.Alpine.plugin(focus)).
Build or serve your frontend assets with npm run dev. In the local environment, the live component showcase is available at /components-demo.
Usage
<x-ui.button variant="danger" size="sm">Delete</x-ui.button> <x-forms.input name="email" type="email" label="Email" hint="We will not share your address." required > <x-slot:icon-left><x-ui.icon name="mail" /></x-slot:icon-left> </x-forms.input> <x-ui.modal name="confirm" title="Confirm">Continue?</x-ui.modal> <x-ui.button x-on:click="$dispatch('open-modal-confirm')">Open dialog</x-ui.button>
Component props, slots, and usage examples are documented in the header comments at the top of each file under resources/components.
| Directory | Components |
|---|---|
ui/ |
spinner icon button badge alert avatar avatar-group card dropdown dropdown-item popover modal drawer command-palette tabs tab-panel accordion accordion-item tooltip toast breadcrumb sidebar-link table data-table pagination progress skeleton empty-state stat-card steps timeline timeline-item theme-toggle |
forms/ |
label input password select textarea checkbox radio radio-group switch file combobox date-picker otp-input tag-input rating range |
layouts/ |
base guest app |
Layouts
layouts/base— shared HTML document shell that setslang/dirfromapp()->getLocale()andrtl_locales, initializes dark mode before paint, loads fonts and@viteentries, and renders<x-ui.toast />.layouts/guest— public/auth layout built onlayouts/basewith a theme toggle and centered content slot.layouts/app— dashboard shell built onlayouts/basefeaturing a collapsible desktop sidebar (state saved inlocalStorageundermavix-ui.sidebar), a focus-trapped mobile drawer, a skip-to-content link, andbrand,sidebar,sidebar-footer,header, andtopbarslots (pair with<x-ui.sidebar-link>).
Server-side toast notifications
Because <x-ui.toast /> is included in all package layouts, you can flash notifications directly from controllers before redirecting:
return redirect()->route('users.index')->toast('User saved.'); return back()->toast('Unable to delete record.', 'danger', title: 'Error', duration: 8000);
You can also queue toasts anywhere in a request via MavixUi\Support\Toast (success, info, warning, danger, flash) or plain ->with('toast', [...]). Multiple toasts in the same request are preserved, and duration: 0 creates a sticky toast that remains visible until dismissed.
Localization (i18n)
All default UI labels ("Close", "Previous", "Today", etc.) come from the package translation files and follow app()->getLocale(). Arabic (ar) and English (en) are included out of the box, and any other locale falls back to config('app.fallback_locale').
php artisan vendor:publish --tag=mavix-ui-lang # -> lang/vendor/mavix-ui
To add a new language, create lang/vendor/mavix-ui/fr/messages.php (copy the en file and translate its values), or edit existing labels. To override a label for a single component instance, pass the corresponding prop directly:
<x-ui.modal name="m" close-label="Dismiss">…</x-ui.modal>
Note: The
/components-demoshowcase page and the publishable starter stubs (mavix-ui-login,mavix-ui-auth,mavix-ui-dashboard) contain Arabic sample copy because they are starter templates meant to be customized.
Component prefix (avoiding name collisions)
By default, components are rendered as <x-ui.button> and <x-forms.input>. If your application defines components with the same names, configure a prefix:
MAVIX_UI_PREFIX=mui
(or set 'prefix' => 'mui' in config/mavix-ui.php). Component tags then become:
<x-mui::button variant="danger">Delete</x-mui::button> <x-mui::input name="email" label="Email" /> <x-mui::ui.button>…</x-mui::ui.button> {{-- grouped syntax also works --}}
- When a prefix is set, the unprefixed tags (
<x-ui.button>) are not registered by the package, freeing those names for your application's own components. Package components are registered as explicit aliases rather than an anonymous component path so they never hijack generic tags like<x-button>. - Internal references between package components (for example,
alertrenderingicon) always use the fixed private namespace<x-mavix-ui::ui.icon>, so they are never affected by your prefix or shadowed by application components. - When changing the prefix, update your existing Blade templates. For example, to rewrite templates from the default syntax to
mui:
grep -rlE '<x-(ui|forms|layouts)\.' resources/views | xargs sed -i -E 's#<(/?)x-(ui|forms|layouts)\.#<\1x-mui::\2.#g'
- The
/components-demoroute automatically rewrites its tags to your configured prefix at render time. Publishable starter stubs (mavix-ui-login,mavix-ui-auth,mavix-ui-dashboard) should be rewritten with the command above if you use a prefix. - A prefix must start with a letter and contain only letters, numbers, and hyphens; otherwise, booting fails early with a clear exception.
Class merging (Tailwind Merge)
When passing a custom class attribute to a component, conflicting utilities (such as px-2 vs. px-4) depend on CSS stylesheet order rather than attribute order. Install the Tailwind v4 merge package so caller classes automatically override conflicting component defaults:
composer require stamat/tailwind-merge-php
<x-ui.button class="bg-red-500 px-8">Delete</x-ui.button> {{-- bg-brand-600 and px-4 are removed; hover:bg-brand-700 is kept because it has a different modifier --}}
No configuration is needed; class merging activates automatically when the package is installed. You can control it in config/mavix-ui.php:
merge_classes |
Behavior |
|---|---|
'auto' (default) |
Enabled automatically when stamat/tailwind-merge-php is installed |
true |
Required; booting fails with a clear exception if the package is not installed |
false |
Disabled; caller classes are appended after component classes without conflict resolution |
- Why
stamat/tailwind-merge-php? Package components use Tailwind CSS v4 utilities (shadow-xs,outline-hidden,size-*), andstamat/tailwind-merge-phpexplicitly targets v4.gehrisandro/tailwind-merge-phptargets Tailwind v3 and is not used automatically because it can mishandle v4 utility groups. - Custom merger implementation: Implement
MavixUi\Support\ClassMergerand bind it in your application container:
$this->app->singleton(\MavixUi\Support\ClassMerger::class, MyMerger::class);
- Internal conflicts within a component's own default classes (such as the focus ring color on the
successbutton variant) are also resolved deterministically. - In published or custom components, use
$attributes->twClass([...])instead of$attributes->class([...]); it falls back to standard concatenation when no merger package is installed.
Configuration and customization
Publish only the files you want to customize:
php artisan vendor:publish --tag=mavix-ui-config # config/mavix-ui.php php artisan vendor:publish --tag=mavix-ui-lang # lang/vendor/mavix-ui php artisan vendor:publish --tag=mavix-ui-components # copy components to resources/views/components php artisan vendor:publish --tag=mavix-ui-views # demo and pagination views php artisan vendor:publish --tag=mavix-ui-login # sign-in page stub in resources/views/auth/login.blade.php php artisan vendor:publish --tag=mavix-ui-auth # all auth stubs (login, register, forgot/reset password) php artisan vendor:publish --tag=mavix-ui-dashboard # dashboard example in resources/views/dashboard.blade.php
Options in config/mavix-ui.php:
| Option | Purpose |
|---|---|
vite |
Vite entry points loaded by layouts/base (guest and app) |
font_url |
External font stylesheet URL (null to disable) |
rtl_locales |
Locales rendered with dir="rtl" by layouts/base (guest and app) |
pagination.default |
When true, ->links() uses the package pagination component across the application |
prefix |
Component tag prefix (null by default); see Component prefix |
merge_classes |
'auto', true, or false; see Class merging |
demo.enabled / demo.path |
Live component demo route (enabled by default in local, or via MAVIX_UI_DEMO=true) |
Changing the brand palette: Override --color-brand-* inside an @theme block in your application's CSS file after importing mavix-ui.css.
Customizing a single component: Publish the components (mavix-ui-components), edit the component you want to customize, and delete any unmodified published component files so they continue receiving package updates.
Name collisions: If your application already has a component with the same name (such as components/ui/button.blade.php), set MAVIX_UI_PREFIX (see Component prefix).
Testing
composer install
composer test
The Pest test suite covers component rendering, layouts, server-side toasts, RTL logical utilities, localization, the service provider, component prefixing, class merging, the install command, publishable stubs, and the demo route.
Browser tests (Playwright + axe-core)
Real Blade components are rendered into static HTML fixture pages and tested in a headless Chromium browser with Alpine.js and Tailwind CSS:
npm install
npx playwright install chromium
npm run browser # composer fixtures -> build CSS/JS -> playwright test
The browser suite verifies focus trapping and scroll locking in modals, drawers, command palettes, and the mobile dashboard sidebar; keyboard navigation across dropdowns, popovers, tabs (including RTL reversal), comboboxes, data tables, OTP inputs, tag inputs, and ratings; date-picker min/max bounds; server-flashed and sticky toasts; logical edge placement; and axe-core (WCAG 2.1 A/AA) scans across four modes (LTR/RTL × light/dark) including open interactive states.
Contrast audit
npm run audit:contrast
Computes WCAG contrast ratios for component color pairs and fails if any text pair falls below 4.5:1 or any non-text UI element falls below 3:1.
Accessibility notes
- Input borders (
border-slate-300) have a lower contrast ratio than the 3:1 advisory threshold in WCAG 1.4.11 by design (form fields are always accompanied by a visible label). For projects targeting strict 1.4.11 border contrast or AAA, change the border utility toborder-slate-500after publishing the form components. - A modal with
:closeable="false"must contain at least one focusable element (such as an action button) so@alpinejs/focuscan trap focus inside the dialog. - When
modalordraweris used without atitle, it falls back to thelabelprop (orname) for its accessiblearia-label.
Local development
To test the package from a neighboring directory inside an application, add a path repository to the application's composer.json:
{
"repositories": [
{
"type": "path",
"url": "../mavix-ui",
"options": { "symlink": false }
}
]
}
Then require the development version:
composer require mahmoud-alqudsi/mavix-ui:@dev
Use "symlink": false so Tailwind CSS v4 source scanning picks up the package templates reliably.
Troubleshooting
- Components render without styles: Verify that
mavix-ui.cssis imported inapp.cssafter@import "tailwindcss";. If Tailwind does not pick up the component classes, add@source '../../vendor/mahmoud-alqudsi/mavix-ui/resources';toapp.css. - Modals or menus do not trap focus: Ensure
@alpinejs/focusis installed and registered beforeAlpine.start(). - Dark mode does not apply: Dark mode relies on the
darkclass on<html>. Thelayouts/basecomponent (used bylayouts/guestandlayouts/app) initializes it automatically; for custom layouts, copy the theme initialization script fromresources/components/layouts/base.blade.php.
Contributing
See CONTRIBUTING.md and the Code of Conduct. To report a security vulnerability, see SECURITY.md.
License
Mavix UI is open-source software licensed under the MIT license.