Configuration and build
A reference page for the config file, the build, the fonts, libraries such as charts and maps, and language selection.
Config file
If your application doesn't have the config file, copy it from the package; if the file doesn't exist at all, the package defaults apply:
php artisan vendor:publish --tag=zubazar-ui-config
// config/zubazar-ui.php
'layout' => [
'mode' => 'light', // light mode on the first visit
'brand_color' => 'green', // primary color
'theme_toggle' => false, // hides the light/dark button in the top bar
],
- These are defaults; what the user picks in the theme switcher always comes first (Order of precedence).
- For a key missing from your file, the package default is used. To add a new section to an older file, copy it from
vendor/zubazar/ui/config/zubazar-ui.php;--forcereplaces the whole file. - The package reads no environment variables; if needed, use
env()on the line ('mode' => env('ZUBAZAR_UI_MODE')). - After changing a setting in production, run
php artisan optimize.
Publishing the package's files
php artisan vendor:publish --tag=zubazar-ui-config # config/zubazar-ui.php
php artisan vendor:publish --tag=zubazar-ui-views # resources/views/vendor/zubazar-ui
php artisan vendor:publish --tag=zubazar-ui-pro-config # config/zubazar-ui-pro.php (themes, panel, store)
php artisan vendor:publish --tag=zubazar-ui-pro-views # resources/views/vendor/zubazar-ui-pro
config/zubazar-ui-pro.php only needs the keys you change. Copied views don't receive updates; for a single component: Changing a component.
Layout settings
The layout array is the default look of the panel layouts and of zb:layout.head. null means the package default.
| Key | Default | What it does |
|---|---|---|
mode |
system |
light, dark, or system to follow the device |
theme |
null |
Color theme; null is the built-in light/dark pair (Your own color theme) |
scope |
app |
The scope the choices are kept in, in the browser; the panel uses panel, the store shop |
brand_color |
default |
default, green, red, yellow, blue, gray, dark or #rrggbb |
skin |
default |
bordered: thin lines instead of shadows |
content_width |
full |
full, default (1280 px), wide (1440), wider (1600) or a CSS length; boxed is read as wide (Content width) |
semi_dark |
false |
true: a dark menu in light mode |
sidebar_mode |
expanded |
expanded or collapsed |
navbar_mode |
fixed |
fixed, static or hidden (hides only on wide screens) |
customizer |
false |
true: the theme switcher panel on the right edge |
theme_toggle |
true |
false: hides the light/dark button in the top bar |
Note
Zubazar UI Pro's ready-made layout files turn the theme switcher on with the
customizerprop; to remove the panel, delete the wordcustomizerfromlayouts/admin/vertical.blade.phpandhorizontal.blade.php.
Building
npm install # first time: Vite and Tailwind
npm run build # for production (public/build)
npm run dev # while developing: changes show up instantly
Rebuild when you change the colors or the --zb-* variables, write new Tailwind classes in Blade, change resources/js, or update the packages. Zubazar UI itself doesn't come from npm; package.json uses the vendor/zubazar/ folder Composer installed. composer run dev starts the server, the queue and Vite together.
CSS and JavaScript files
php artisan zubazar:install adds these lines (Manual installation):
@import '@zubazar/ui': the color names (bg-surface,text-muted), the light and dark themes, the component and form field styles. The form styles apply only to fields withdata-zb-control; you can add this attribute to a field you write yourself.@import '@zubazar/ui-pro': the styles of the panel layouts, the form modal and the confirm dialogs.- The
@sourcelines: make Tailwind scan the packages' Blade files; without them, the components appear unstyled. import '@zubazar/ui'andimport '@zubazar/ui-pro': the components' behavior. Alpine comes with Livewire.- One more line for the store:
@import './zb-themes.css';(E-commerce).
The starter kit loads three files on every page; the input list in vite.config.js is the same:
@vite(['resources/css/zubazar-ui.css', 'resources/js/zubazar-ui.js', 'resources/js/app.js'])
zubazar-ui.js is just two import lines; app.js is the application's code. In this setup app.js doesn't import Zubazar UI (otherwise Vite would extract a shared chunk for the two entries); that's why PRO's registration functions are under window.ZubazarUI.pro. A single entry works too: put the two import lines at the top of app.js.
Libraries
You install the library behind the chart, map, date range and DataTables components and register it in resources/js/app.js; Zubazar UI gives it the colors, light and dark mode and the Blade component (Zubazar UI Pro). The registration code is in the Installation section of each component's page.
| Library | Component | Install |
|---|---|---|
| ApexCharts | Charts | npm i apexcharts@^3.54.1 |
| Leaflet | Map | npm i leaflet@^1.9.4 |
| flatpickr | Date range | npm i flatpickr@^4.6.13 |
| DataTables | DataTables | npm i datatables.net |
| Tiptap | Rich text | Comes with Zubazar UI Pro: npm install |
| Swiper | Carousel | Comes with Zubazar UI: npm install |
Charts, maps and date ranges
The registrations sit in one listener; write only the libraries you use:
// resources/js/app.js
document.addEventListener('livewire:init', () => {
const { lazyLibrary, registerChart, registerMap, registerDataTables } = window.ZubazarUI.pro;
registerChart(window.Alpine, lazyLibrary(() => import('apexcharts')));
registerMap(window.Alpine, lazyLibrary(() => import('leaflet/dist/leaflet.css').then(() => import('leaflet'))));
registerDataTables(window.Alpine, lazyLibrary(() => import('datatables.net')));
});
lazyLibrarydownloads the library only on a page with that component, the first time it's used (ApexCharts alone is ~530 kB). You can also pass it directly:registerChart(window.Alpine, ApexCharts); it then ships on every page.- The date range's registration with a Turkish calendar: Date range.
- A component whose library isn't registered writes in the console what to add.
Warning
By default, the map uses OpenStreetMap's free tile server; it doesn't allow heavy production traffic. In production, pass your own provider:
registerMap(Alpine, L, { tileUrl, attribution }).
Heavy components only when needed
The JavaScript of large components such as the combobox, file upload, form modal, tag input, tree, stepper and tour downloads once, only when that component appears on the page; you don't need to do anything. If a chunk can't be downloaded, the console shows [Zubazar UI] The JavaScript of the "…" component could not be loaded.
-
Download a chunk ahead of time for a dialog that's about to open:
ZubazarUI.load('file-upload');. -
Add your own heavy component to the same scheme:
window.ZubazarUI.components.define('editor', () => import('./components/editor.js').then((module) => module.register(window.Alpine)));<div data-zb-component="editor" x-data="editor(@js($ayarlar))">…</div> -
registerFileUploadandregisterFormModaldownload the chunk first and return a Promise;registerComboboxdoes nothing now (it stays until 3.0).
Fonts
The default fonts are Public Sans for text and DM Mono for code and numbers. Load them from vite.config.js:
import { bunny } from 'laravel-vite-plugin/fonts';
import { woff2Only } from '@zubazar/ui/vite';
plugins: [
laravel({
input: ['resources/css/zubazar-ui.css', 'resources/js/zubazar-ui.js', 'resources/js/app.js'],
fonts: [
bunny('Public Sans', { weights: [400, 500, 600, 700], subsets: ['latin', 'latin-ext'], preload: [{ weight: 400 }, { weight: 600 }] }),
bunny('DM Mono', { weights: [400, 500], subsets: ['latin', 'latin-ext'], preload: false }),
],
}),
woff2Only(),
tailwindcss(),
],
Add @zubazarFonts(['public-sans', 'dm-mono']) to the layout's head slot. latin-ext contains the Turkish letters. The fonts are downloaded from Bunny Fonts during the build and put in public/build; the live site doesn't connect to Bunny Fonts. php artisan zubazar:themes writes the fonts of the store themes. Another font: Fonts and corners.
Font details
woff2Only()keeps only the WOFF2 files in the build (add it afterlaravel()); otherwise the browser downloads the larger WOFF files.preloadpreloads only the weights needed on the first screen (400 and 600); without it, all 12 files are preloaded and the browser warns "preloaded but not used".@zubazarFontsprints the same preload tags as Laravel's@fontsdirective, but instead of writing the@font-facerules inline, it links the cachedfonts-*.cssfile. You can ask for only some families, e.g.@zubazarFonts(['public-sans']).
Bundled fonts
The package carries and serves 20 Google Fonts families with Turkish letters (ç, ğ, ı, İ, ö, ş, ü); no request goes to Google or any other font host. Each family comes in weights 400, 500, 600 and 700 (Lato 400 and 700; the browser uses the nearest), in the latin and latin-ext subsets, as WOFF2.
| Font | Id | Kind | Suited to |
|---|---|---|---|
| Public Sans | public-sans |
Sans-serif | The default, admin panels |
| Inter | inter |
Sans-serif | ERP, CRM, dense data screens |
| Manrope | manrope |
Sans-serif | Modern corporate sites |
| DM Sans | dm-sans |
Sans-serif | SaaS and stores |
| Plus Jakarta Sans | plus-jakarta-sans |
Sans-serif | Modern, strong headings |
| Roboto | roboto |
Sans-serif | General interfaces |
| Open Sans | open-sans |
Sans-serif | Corporate and long texts |
| Source Sans 3 | source-sans-3 |
Sans-serif | Forms and panels |
| Nunito Sans | nunito-sans |
Sans-serif | Soft, friendly interfaces |
| Lato | lato |
Sans-serif | Corporate designs (400 and 700) |
| Montserrat | montserrat |
Sans-serif | Showcases and headings |
| Poppins | poppins |
Sans-serif | Geometric, modern designs |
| Work Sans | work-sans |
Sans-serif | Plain web interfaces |
| IBM Plex Sans | ibm-plex-sans |
Sans-serif | Technical and industrial sites |
| Noto Sans | noto-sans |
Sans-serif | Multilingual projects |
| Outfit | outfit |
Sans-serif | Fashion and modern stores |
| Lora | lora |
Serif | Elegant content and boutique sites |
| Merriweather | merriweather |
Serif | Reading-focused pages |
| Playfair Display | playfair-display |
Serif | Luxury brand headings |
| Source Serif 4 | source-serif-4 |
Serif | Editorial and corporate content |
The text and heading fonts are layout settings; without one, the theme's own font is used:
// config/zubazar-ui.php
'layout' => [
'font' => 'inter', // text, buttons, logo
'heading_font' => 'playfair-display', // headings
],
- The page links only the chosen family's files, and the browser downloads only the weights and letters the page uses; the other families are never downloaded.
- The text font's 400 and 600 weights are preloaded for the first paint.
- When a chosen font replaces the theme's,
@zubazarFontsno longer preloads the theme's font. zb:layout.headprints the tags itself; you don't need to add anything.
The administrator's choice (database). The kit stores nothing on the server; your application keeps the choice and hands it to the kit:
// AppServiceProvider::boot()
use Zubazar\Ui\Support\FontLibrary;
FontLibrary::using(fn () => [
'text' => Setting::value('font'),
'heading' => Setting::value('heading_font'),
]);
In the admin screen, the field is zb:font-select. It groups the families, its first option is the theme's own font, and it shows a sample line in the chosen font:
<zb:font-select :label="__('Text font')" wire:model.live="font" />
<zb:font-select :label="__('Heading font')" wire:model.live="headingFont" :preview="false" />
Order: Layout::page(['font' => …]) (that page only), then FontLibrary::using(), then config. An id the library doesn't have is ignored. To serve the files from the web server, run php artisan vendor:publish --tag=zubazar-ui-fonts; the licence files are copied too. With zubazar-ui.assets.url (a CDN), the files come from its fonts/ folder.
Laravel 12
laravel-vite-plugin/fonts and the fonts option are part of laravel-vite-plugin 3, which comes with Laravel 13; in Laravel 12 this import stops the build. Remove the bunny import and the fonts lines from vite.config.js.
In Laravel 12, @zubazarFonts links Public Sans and DM Mono from fonts.bunny.net. If you don't want the browser to go to a third-party server (CSP, KVKK/GDPR), set 'fonts_fallback' => false in config/zubazar-ui.php and serve the fonts yourself with Fontsource:
npm install @fontsource/public-sans @fontsource/dm-mono
/* resources/css/zubazar-ui.css, before Tailwind */
@import '@fontsource/public-sans/400.css';
@import '@fontsource/public-sans/500.css';
@import '@fontsource/public-sans/600.css';
@import '@fontsource/public-sans/700.css';
@import '@fontsource/dm-mono/400.css';
@import '@fontsource/dm-mono/500.css';
php artisan zubazar:install --check tells you which one applies.
Page-specific code
@push('page-scripts')
@vite('resources/js/pages/report.js')
@endpush
The built-in layouts output @stack('page-scripts') before </body>; also add the file to the input list in vite.config.js. When wire:navigate returns to the same page, the module doesn't run again; put code that must run on every visit inside document.addEventListener('livewire:navigated', …).
With Alpine
Alpine comes with Livewire; don't install it separately. The components' behavior doesn't depend on Alpine: it works next to your own Alpine code on the same page, and components added later with x-if or x-for start by themselves.
Listen to the components' events with x-on. They bubble from the component up to window:
<div x-data="{ tab: 'general', open: false }"
x-on:zb:tabs:change="tab = $event.detail.value"
x-on:zb:collapse:change="open = $event.detail.open"
x-on:zb:modal:closed.window="if ($event.detail.name === 'customer') $wire.$refresh()">
…
</div>
Command the components with $dispatch:
<button type="button" x-on:click="$dispatch('zb:modal:open', { name: 'customer' })">New customer</button>
<button type="button" x-on:click="$dispatch('zb:drawer:open', { name: 'filters' })">Filters</button>
<button type="button" x-on:click="$dispatch('toast', { type: 'success', message: 'Copied' })">Copy</button>
| Event | When | detail |
|---|---|---|
zb:modal:opened / zb:modal:closed |
A modal opens / closes | name, reason on closing |
zb:drawer:opened / zb:drawer:closed |
A drawer opens / closes | name |
zb:tabs:change |
The open tab changes | value |
zb:collapse:change |
A collapse opens or closes | open |
zb:carousel:change |
A carousel's slide changes | index, count |
Commands: zb:modal:open, zb:modal:close, zb:drawer:open, zb:drawer:close, zb:drawer:toggle (with name; closing without one closes them all) and toast (type, message). The same from Livewire: $this->dispatch('zb:modal:open', name: 'customer').
In Blade, write the event with x-on:, not the @ shorthand: @zb… may be read as a Blade directive. For the theme and colour, Alpine's $store.appearance: Theming › Appearance in JavaScript. To use Alpine on a page without Livewire, load it yourself; the components work without it too.
Fly-to-cart effect
ZubazarUI.flyToCart(source, target) flies a copy of a product picture to the cart: the copy shrinks into a small round thumbnail on its way, is removed on arrival, and the cart gives a little bounce. It's only the look; it adds nothing to a cart. Call it after your add has succeeded:
// Once your Livewire component has added: $this->dispatch('product-added', id: $product->id);
Livewire.on('product-added', ({ id }) => {
ZubazarUI.flyToCart(`#product-${id} img`, '[data-zb-cart-target]');
});
sourceandtargetare elements or selectors. If the source is an<img>(or holds one), that image flies; otherwise the element itself is copied (a drawing).- Options:
duration(milliseconds, default 700),size(pixels on arrival, 28),bounce(false: the cart doesn't bounce),origin(the button pressed: when the picture's centre is off screen or under the header, a card scrolled up, a small copy of it flies from here). - It returns a
Promise:trueonce the copy has arrived. With reduced motion, when the cart is off screen, or when both the source andoriginare, nothing moves and it resolvesfalseat once. - Several adds in a row fly side by side; the bounce starts again with each arrival. The target gets an
zb:fly-to-cart:arrivedevent on arrival. - No extra library (the browser's Web Animations API). The code is a small chunk loaded on the first flight.
In an Zubazar UI Pro store this works by itself: the product card and the product page fly the picture to the cart link marked data-zb-cart-target once your Livewire component sends cart-updated (the add succeeded); when the picture is off screen or under the header the flight starts from the button pressed.
Language and translation
Zubazar UI comes with a Turkish and an English interface; components show in the application's current language (app()->getLocale()). Your application decides which language is chosen and where it's stored; the kit draws the language switcher.
Language switcher
<zb:locale-switcher
:action="route('locale')"
:locales="['tr' => 'Türkçe', 'en' => 'English']"
:flags="['en' => 'gb']"
/>
// routes/web.php
Route::post('/locale', function (Request $request) {
$locale = $request->string('locale')->toString();
abort_unless(in_array($locale, ['tr', 'en'], true), 422);
return back()->withCookie(cookie()->forever('locale', $locale));
})->name('locale');
The switcher POSTs the chosen language to the action address in a locale field; you set each request's language in a middleware with app()->setLocale().
| Prop | What it does | Default |
|---|---|---|
action |
Where the choice is sent; without it the switcher isn't drawn | null |
locales |
The offered languages: code => its name in its own language | [] |
flags |
Flags whose code differs from the language code (['en' => 'gb']); false shows no flags |
The language code |
current |
The selected language | app()->getLocale() |
align |
The list's alignment: end or start |
end |
With one language offered, the switcher doesn't show. Known flags: tr, gb, us, de, fr, es, it, nl, ru.
The starter kit's ready-made code
| File | What it does |
|---|---|
app/Zubazar/Localization.php |
Reads the languages, picks the visitor's language |
app/Zubazar/Http/Middleware/SetLocale.php |
Sets each request's language (in the web group) |
app/Zubazar/Http/LocaleController.php |
Writes the choice to a cookie and, if you want, to the account |
config/zubazar.php (locale) |
The offered languages, the fallback language, country mappings, the cookie and the account field |
resources/views/components/locale-switcher.blade.php |
Calls the kit's switcher with these settings (<x-locale-switcher />) |
SetLocale picks the language in this order: the saved preference (the account, else the cookie), the browser's language, the country (Cloudflare, CloudFront, Vercel headers) and the fallback language; it adds Vary: Accept-Language, Cookie to the response.
Single-language application
Write 'supported' => ['tr'] in config/zubazar.php; the switcher doesn't show. Or don't set up the language choice at all: set APP_LOCALE=tr in .env and delete the SetLocale line, the locale route and the <x-locale-switcher /> line. If the store's languages() method returns one language, the switcher doesn't show in the themes either.
The package's texts
The package's texts ("Close", "Clear selection"…) are translation keys; the key is the English text. Write the same key into your application's lang/tr.json or lang/en.json and yours is used:
{ "Clear selection": "Seçimi kaldır" }
Every key is in vendor/zubazar/ui/lang/tr.json and vendor/zubazar/ui-pro/lang/tr.json; for a new language, translate them into that language's file and add the language to the locales list.
The application's texts
Pass the texts you give the components through __(); if you write in Turkish, the key can be Turkish (:title="__('Kullanıcıyı sil')", with "Kullanıcıyı sil": "Delete user" in lang/en.json). Titles in the JSON menu and a Livewire page's #[Title] value are translation keys too.
Plural texts
Warning
trans_choice()looks for the key only in that language's JSON file and falls back to the fallback language otherwise. In an application with Turkish keys, write every key you use withtrans_choice()intolang/tr.json, mapped to itself.
// lang/tr.json
{ ":count ürün|:count ürün": ":count ürün|:count ürün" }
// lang/en.json
{ ":count ürün|:count ürün": ":count product|:count products" }
Number format and search
The components' numbers follow the page's language (1.234,5 · 1,234.5); in your own templates, \Zubazar\Ui\Support\Format::number(1234.5, 1) gives the same format. zb:combobox's search ignores Turkish letters (typing "sisli" finds "Şişli"); searches on the server are your own queries.
Without Vite
If you don't use Vite, load the compiled JavaScript that ships with the packages with @zubazarUiScripts (in the layout's head slot or before </body>):
<zb:layout.sidebar brand-name="My App">
<zb:slot:head>
@zubazarUiScripts
</zb:slot:head>
{{ $slot }}
</zb:layout.sidebar>
- The package serves the shared JavaScript by itself from
/zubazar-ui/zubazar-ui.js?id=…with a one-year cache. - The package doesn't serve the PRO file by itself (so Zubazar UI Pro doesn't sit at a public address). Pick one of three ways:
panel.assets.route=>trueinconfig/zubazar-ui-pro.php, publishing the file (php artisan vendor:publish --tag=zubazar-ui-pro-assets), or a CDN URL withpanel.assets.url. If you published it, republish with--forceafter every update. - The boot file (
zubazar-ui-boot.js) is written byzb:layout.headin every application; it applies the mode and the color before the first paint.
JavaScript file URLs
| Key | Default | What it does |
|---|---|---|
assets.prefix |
'zubazar-ui' |
URL prefix: /zubazar-ui/zubazar-ui-boot.js, /zubazar-ui/zubazar-ui.js |
assets.url |
null |
A CDN folder holding the files |
panel.assets.route (zubazar-ui-pro) |
false |
true: the package serves the PRO file from /zubazar-ui/zubazar-ui-pro.js |
panel.assets.prefix (zubazar-ui-pro) |
'zubazar-ui' |
The PRO file's URL prefix |
panel.assets.url (zubazar-ui-pro) |
null |
The full CDN URL of the PRO file |
Content Security Policy
If you use a CSP, pass a nonce; without one, Vite::cspNonce() is used (in Laravel, Vite::useCspNonce() is enough):
@zubazarUiScripts(['nonce' => $nonce])
<zb:layout.head :nonce="$nonce">…</zb:layout.head>
| Directive | Value | Why |
|---|---|---|
script-src |
'self' 'nonce-…' 'unsafe-eval' |
Alpine (it comes with Livewire) runs expressions in the browser; the chart, map, date range, DataTables, file upload and your own Alpine code use this |
style-src |
'self' 'unsafe-inline' |
Some components write a style attribute (progress bar, icon size) |
img-src |
'self' data: blob: |
blob: is for the file upload's previews; if you don't want it, :previews="false" |
connect-src |
'self' |
Livewire requests and the chunks loaded later |
font-src |
'self' |
The fonts come from the same address as the build (in Laravel 12, for Bunny Fonts see Laravel 12) |
Select box fix
When Livewire updates a <select> box, the browser sometimes keeps showing the old option. The fix is off by default; to turn it on, write 'select_sync' => true in config/zubazar-ui.php. To turn it on for one part only, add data-zb-select-sync to the container; for a single field, use zb:select :sync="true".
Troubleshooting
If the shared JavaScript isn't loaded
The console shows the [Zubazar UI] JavaScript is not loaded: … error; drawers and modals don't open, and the appearance settings don't work. Add the import '@zubazar/ui'; line to your JavaScript entry (resources/js/zubazar-ui.js in the starter kit) and build, or add @zubazarUiScripts to the layout.
If the PRO JavaScript isn't loaded
On a page with zb:combobox, zb:file-upload, zb:form-modal or zb:form dirty-check, the console shows [Zubazar UI Pro] JavaScript is not loaded: … and these fields stay unclickable. Add import '@zubazar/ui-pro'; to your Vite entry and rebuild; without Vite, see Without Vite.
- "The JavaScript file could not be loaded":
@zubazarUiScriptsis there but the file didn't arrive; update your published copy with--force. - "@zubazarUiScripts has no address for zubazar-ui-pro.js": the PRO file has no URL; pick one of the three ways above.
- "The JavaScript was loaded twice": two copies of the PRO entry are running (e.g. two Vite entries import the same line); remove one.
Type ZubazarUI.pro in the console to see that the PRO JavaScript is loaded, and its version.
Learn more
- Installation: installing from scratch and deploying.
- Appearance: colors, the mode, the theme switcher and the precedence of defaults.