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
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">.
<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>
| Prop | Values |
|---|---|
class | Added to the container; px-* changes the gutter |
Width
Without width the container follows the page's width; with it, only this container takes that width.
<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>
| Prop | Values |
|---|---|
width | default | wide | wider | full | 1520px |
as | div | section | header | footer | main | nav | article | aside |
A grid that follows the container
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.
<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
The layout writes the page's width on <html> before the first paint; the details: Content width.
// 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?
| Prop | Type | Default | Description |
|---|---|---|---|
width | — | null | default (1280px) · wide (1440px) · wider (1600px) · full · a CSS length (1520px, 90rem); boxed is wide; null: the page's width |
as | — | div | div · section · header · footer · main · nav · article · aside |
Slots: default (the content)
Developer notes
- The navbar, the page and the footer use the same container, so they line up on every screen; the same is the
zb-containerclass. - 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>; awidthvalue it doesn't know counts asdefault. - Put
@containeron 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-widthprop, a package's default (default-content-width; in the storecommerce.content_width), and lastconfig('zubazar-ui.layout.content_width'); with none of them,full. In the panel the user changes the width in the theme switcher.