Container
A centered content-width primitive with semantic max-width and density-aware gutter tiers.
Preview
<x-ui.container size="sm" class="rounded-lg border border-border bg-card py-6 text-center text-card-foreground">
{{ __('Bounded, centered content') }}
</x-ui.container>
Installation
php artisan ui:add container
Registry contract
php artisan ui:add container
writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.
-
resources/views/components/ui/container.blade.php
- Registry dependencies
- None — installs on its own.
- Packages
-
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.
# Brok UI: Container (`container`)
A centered content-width primitive with semantic max-width and density-aware gutter tiers.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add container
```
## Usage
```blade
<x-ui.container size="sm" class="rounded-lg border border-border bg-card py-6 text-center text-card-foreground">
{{ __('Bounded, centered content') }}
</x-ui.container>
```
## Props
- `size` (sm|md|lg|xl|full, default `lg`) — Max-width tier, equivalent to Tailwind's own scale: `sm` 42rem (`max-w-2xl`), `md` 56rem (`max-w-4xl`), `lg` 72rem (`max-w-6xl`) — the dominant block container width (`mx-auto max-w-6xl px-4`, 90 files), `xl` 80rem (`max-w-7xl`), `full` unbounded.
- `gutter` (none|sm|md|lg, default `md`) — Responsive side padding tier.
- `centered` (boolean, default `true`) — Applies `mx-auto` to centre the container.
- `as` (div|section|main|nav|aside|header|footer, default `div`) — Rendered element tag.
## Use when
- Use to structure hierarchy, spacing, and responsiveness so content is easier to scan and navigate.
- Bounding a block or page's content to a readable, centred width.
- Wrapping a section's contents in a fixed max-width column with responsive side gutters.
## Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- The region should bleed full-width; render the children directly instead.
## Anti-patterns
- Using visual layout as a substitute for semantic structure
## Rules
- Use the `<brok:container>` tag (or `<x-ui.container>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.
## Links
- Docs: https://brokui.dev/docs/components/container
- Registry JSON (files, props, contract): https://brokui.dev/r/open/container.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| size | sm | md | lg | xl | full | lg | Max-width tier, equivalent to Tailwind's own scale: `sm` 42rem (`max-w-2xl`), `md` 56rem (`max-w-4xl`), `lg` 72rem (`max-w-6xl`) — the dominant block container width (`mx-auto max-w-6xl px-4`, 90 files), `xl` 80rem (`max-w-7xl`), `full` unbounded. |
| gutter | none | sm | md | lg | md | Responsive side padding tier. |
| centered | boolean | true | Applies `mx-auto` to centre the container. |
| as | div | section | main | nav | aside | header | footer | div | Rendered element tag. |
Slots
default— Primary Blade slot rendered by the component.
Renders as div, section, main, nav, aside, header, footer.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Uses server-rendered Blade and semantic HTML.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Structure content hierarchy and responsive relationships.
Use when
- Use to structure hierarchy, spacing, and responsiveness so content is easier to scan and navigate.
- Bounding a block or page's content to a readable, centred width.
- Wrapping a section's contents in a fixed max-width column with responsive side gutters.
Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- The region should bleed full-width; render the children directly instead.
Use instead
- Semantic HTML with standard flow
Anti-patterns
- Using visual layout as a substitute for semantic structure
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- No component-owned keyboard interaction; native element behavior applies.
- Focus
none
- Renders a plain <div> by default and adds no role; switch as= to a landmark (main, nav, aside, header, footer) only when this container is that landmark.
- Semantic HTML and a stable
data-slotattribute for styling and scripting hooks. - Focus-visible rings use the
ringtoken, so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
- Labels go through
__()and layout uses logical properties (ms-*,text-start), so it mirrors underdir="rtl"— flip the preview to RTL to confirm. - Dark mode uses the same semantic tokens under the
darkclass; high contrast follows forced-color system tokens.
Livewire
Livewire can update this component through forwarded wire:* attributes.
Source
The exact, editable file ui:add writes
into your app. Previews render this same code; there are no preview-only components.
@props([
'size' => 'lg',
'gutter' => 'md',
'centered' => true,
'as' => 'div',
])
@php
$allowedTags = ['div', 'section', 'main', 'nav', 'aside', 'header', 'footer'];
$tag = in_array($as, $allowedTags, true) ? $as : 'div';
$sizes = [
'sm' => 'max-w-content-sm',
'md' => 'max-w-content-md',
'lg' => 'max-w-content-lg',
'xl' => 'max-w-content-xl',
'full' => 'max-w-none',
];
$gutters = [
'none' => '',
'sm' => 'px-gutter-sm',
'md' => 'px-gutter-md',
'lg' => 'px-gutter-lg',
];
$sizeKey = array_key_exists($size, $sizes) ? $size : 'lg';
$gutterKey = array_key_exists($gutter, $gutters) ? $gutter : 'md';
// A block that composes this container may pass its own data-slot;
// the browser keeps only the first of two identical attributes, so read
// the override and print exactly one.
$slotName = (string) ($attributes->get('data-slot') ?: 'container');
@endphp
<{{ $tag }}
data-slot="{{ $slotName }}"
data-size="{{ $sizeKey }}"
{{ $attributes->except('data-slot')->merge(['class' => trim('w-full min-w-0 '.$sizes[$sizeKey].' '.$gutters[$gutterKey].' '.($centered ? 'mx-auto' : ''))]) }}
>{{ $slot }}</{{ $tag }}>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.6 - Status
- Stable
- License
-
open - Accessibility reviewed
- No review date recorded
- Last breaking change
- No date recorded
- Deprecation
- Not deprecated
- Contract
-
v6 - Foundation
-
≥ 1.0.0