Section
A semantic page-section primitive with density-aware vertical rhythm and tokenized surface tones.
Preview
Section rhythm
<x-ui.section space="8" surface="muted" class="w-full rounded-lg text-center">
<h3 class="text-lg font-semibold">{{ __('Section rhythm') }}</h3>
</x-ui.section>
Installation
php artisan ui:add section
Registry contract
php artisan ui:add section
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/section.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: Section (`section`)
A semantic page-section primitive with density-aware vertical rhythm and tokenized surface tones.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add section
```
## Usage
```blade
<x-ui.section space="8" surface="muted" class="w-full rounded-lg text-center">
<h3 class="text-lg font-semibold">{{ __('Section rhythm') }}</h3>
</x-ui.section>
```
## Props
- `space` (none|sm|md|lg|xl, default `md`) — Vertical padding tier. `sm` 32px, `md` 48px, `lg` 48→64px (responsive from `sm:`), `xl` 64→96px (responsive from `sm:`) — the dominant marketing-block rhythm (`py-16 sm:py-24`). Numeric aliases `8`/`12`/`16` map to `sm`/`md`/`lg` for backward compatibility.
- `surface` (default|card|muted|primary|transparent, default `default`) — Background/foreground token pairing for the section.
- `as` (section|div|main|aside|header|footer, default `section`) — Rendered element tag.
## Use when
- Use to structure hierarchy, spacing, and responsiveness so content is easier to scan and navigate.
- Wrapping a page or landing-page section that needs consistent vertical padding.
- A marketing block needs the py-16 sm:py-24 rhythm (`space="xl"`).
## Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- The region is a control or card, not a page-level section; use `surface` or `card` instead.
- You need a bounded content width — pair with `<x-ui.container>` inside the section.
## Anti-patterns
- Using visual layout as a substitute for semantic structure
## Rules
- Use the `<brok:section>` tag (or `<x-ui.section>`) 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/section
- Registry JSON (files, props, contract): https://brokui.dev/r/open/section.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 |
|---|---|---|---|
| space | none | sm | md | lg | xl | md | Vertical padding tier. `sm` 32px, `md` 48px, `lg` 48→64px (responsive from `sm:`), `xl` 64→96px (responsive from `sm:`) — the dominant marketing-block rhythm (`py-16 sm:py-24`). Numeric aliases `8`/`12`/`16` map to `sm`/`md`/`lg` for backward compatibility. |
| surface | default | card | muted | primary | transparent | default | Background/foreground token pairing for the section. |
| as | section | div | main | aside | header | footer | section | Rendered element tag. |
Slots
default— Primary Blade slot rendered by the component.
Renders as section, div, main, 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.
- Wrapping a page or landing-page section that needs consistent vertical padding.
- A marketing block needs the py-16 sm:py-24 rhythm (`space="xl"`).
Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- The region is a control or card, not a page-level section; use `surface` or `card` instead.
- You need a bounded content width — pair with `<x-ui.container>` inside the section.
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 <section> by default, which is a region landmark only when it has a name: give it aria-labelledby (its heading id) or aria-label when it holds a distinct part of the page.
- Use as="main", "header", "footer" or "aside" only for the real page landmark; a page has one main.
- 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([
'space' => 'md',
'surface' => 'default',
'as' => 'section',
])
@php
$allowedTags = ['section', 'div', 'main', 'aside', 'header', 'footer'];
$tag = in_array($as, $allowedTags, true) ? $as : 'section';
$spaces = [
'none' => '',
'sm' => 'py-section-sm',
'md' => 'py-section-md',
'lg' => 'py-section-md sm:py-section-lg',
'xl' => 'py-section-lg sm:py-section-xl',
'8' => 'py-section-sm',
'12' => 'py-section-md',
'16' => 'py-section-md sm:py-section-lg',
];
$surfaces = [
'default' => 'bg-background text-foreground',
'card' => 'bg-card text-card-foreground',
'muted' => 'bg-muted text-foreground',
'primary' => 'bg-primary text-primary-foreground',
'transparent' => 'text-foreground',
];
$spaceKey = array_key_exists((string) $space, $spaces) ? (string) $space : 'md';
$surfaceKey = array_key_exists($surface, $surfaces) ? $surface : 'default';
// A block that composes this section 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') ?: 'section');
@endphp
<{{ $tag }}
data-slot="{{ $slotName }}"
data-space="{{ $spaceKey }}"
data-surface-tone="{{ $surfaceKey }}"
{{ $attributes->except('data-slot')->merge(['class' => trim('min-w-0 max-w-full '.$spaces[$spaceKey].' '.$surfaces[$surfaceKey])]) }}
>{{ $slot }}</{{ $tag }}>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.2.4 - 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