v0.0.2
Demos (demo panel, opens in a new tab)

Page container

A container that centers the content, grows it up to the page's content width and carries its own gutter.

zb:container zubazar/ui · free (MIT)

Basic usage

Basic usage: view
BLADE

The band's background stays full width and its content goes into the container; instead of the component you may write <div class="zb-container">.

blade
<div class="bg-sunken">
    <zb:container class="flex h-14 items-center justify-between gap-3">
        <span class="font-semibold text-ink">Acme Store</span>
        <zb:button size="sm" variant="white">Cart</zb:button>
    </zb:container>
</div>
PropValues
classAdded to the container; px-* changes the gutter

Width

Width: view
BLADE

Without width the container follows the page's width; with it, only this container takes that width.

blade
<div class="space-y-2 text-sm text-primary-tint-ink">
    <zb:container width="24rem" class="rounded-sm bg-primary-tint py-3">24rem</zb:container>
    <zb:container width="36rem" class="rounded-sm bg-primary-tint py-3">36rem</zb:container>
    <zb:container width="full" class="rounded-sm bg-primary-tint py-3">full</zb:container>
</div>
PropValues
widthdefault | wide | wider | full | 1520px
asdiv | section | header | footer | main | nav | article | aside

A grid that follows the container

A grid that follows the container: view
BLADE

To pick the grid's columns by its own width rather than the screen's, put @container on a wrapper and container queries such as @lg: on the grid.

blade
<zb:container width="40rem">
    <div class="@container">
        <div class="grid grid-cols-2 gap-3 @lg:grid-cols-3 @2xl:grid-cols-4">
            @foreach (range(1, 6) as $i)
                <div class="rounded-sm bg-sunken p-4 text-center text-sm text-dim">Product {{ $i }}</div>
            @endforeach
        </div>
    </div>
</zb:container>

The page's width

PHP

The layout writes the page's width on <html> before the first paint; the details: Content width.

php
// config/zubazar-ui.php: the panel's and the application's default
'layout' => ['content_width' => 'wide'],

// .env: the store's width (config/zubazar-ui-pro.php, commerce.content_width)
SHOP_CONTENT_WIDTH=wider

// One page: in a controller or a Livewire component's mount() method
\Zubazar\Ui\Support\Layout::page(['content_width' => '1520px']);

// Your own layout: <zb:layout.blank content-width="wide"> or default-content-width="default"

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
width—nulldefault (1280px) · wide (1440px) · wider (1600px) · full · a CSS length (1520px, 90rem); boxed is wide; null: the page's width
as—divdiv · section · header · footer · main · nav · article · aside

Slots: default (the content)

Developer notes

Events, hooks and details
  • The navbar, the page and the footer use the same container, so they line up on every screen; the same is the zb-container class.
  • The gutter grows from 16 pixels on phones to 32 on desktops (--zb-container-gutter).
  • The page's width is read from <html data-content-width>; a width value it doesn't know counts as default.
  • Put @container on a wrapper inside, not on the container itself; fixed-position menus stay inside an element with a container query. Queries such as @min-[66rem]: work too.
  • The width's order: the value a page forces, the layout's content-width prop, a package's default (default-content-width; in the store commerce.content_width), and last config('zubazar-ui.layout.content_width'); with none of them, full. In the panel the user changes the width in the theme switcher.
Zubazar UI · ZubazarDesigned for people.