Cluster
An overflow-safe inline layout primitive for wrapping actions, tags, filters, and metadata with an approved gap vocabulary.
Preview
{{-- A cluster is a wrapping row with an approved gap: tags, filters, actions
and metadata that must wrap safely at any width. Narrow the frame and the
items flow onto new lines instead of overflowing. --}}
<div class="w-full max-w-md space-y-6">
<x-ui.cluster gap="2">
@foreach (['Design', 'Engineering', 'Marketing', 'Research', 'Operations', 'Support', 'Finance', 'Legal'] as $team)
<x-ui.badge variant="secondary">{{ $team }}</x-ui.badge>
@endforeach
</x-ui.cluster>
{{-- justify="between" pushes the two ends apart while each end still wraps. --}}
<x-ui.cluster gap="3" justify="between">
<x-ui.cluster gap="2">
<x-ui.badge variant="soft-success">{{ __('Published') }}</x-ui.badge>
<span class="text-sm text-muted-foreground">{{ __('Updated 2 hours ago') }}</span>
</x-ui.cluster>
<x-ui.cluster gap="2">
<x-ui.button variant="outline" size="sm">{{ __('Preview') }}</x-ui.button>
<x-ui.button size="sm">{{ __('Save') }}</x-ui.button>
</x-ui.cluster>
</x-ui.cluster>
</div>
Installation
php artisan ui:add cluster
Registry contract
php artisan ui:add cluster
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/cluster.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: Cluster (`cluster`)
An overflow-safe inline layout primitive for wrapping actions, tags, filters, and metadata with an approved gap vocabulary.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add cluster
```
## Usage
```blade
{{-- A cluster is a wrapping row with an approved gap: tags, filters, actions
and metadata that must wrap safely at any width. Narrow the frame and the
items flow onto new lines instead of overflowing. --}}
<div class="w-full max-w-md space-y-6">
<x-ui.cluster gap="2">
@foreach (['Design', 'Engineering', 'Marketing', 'Research', 'Operations', 'Support', 'Finance', 'Legal'] as $team)
<x-ui.badge variant="secondary">{{ $team }}</x-ui.badge>
@endforeach
</x-ui.cluster>
{{-- justify="between" pushes the two ends apart while each end still wraps. --}}
<x-ui.cluster gap="3" justify="between">
<x-ui.cluster gap="2">
<x-ui.badge variant="soft-success">{{ __('Published') }}</x-ui.badge>
<span class="text-sm text-muted-foreground">{{ __('Updated 2 hours ago') }}</span>
</x-ui.cluster>
<x-ui.cluster gap="2">
<x-ui.button variant="outline" size="sm">{{ __('Preview') }}</x-ui.button>
<x-ui.button size="sm">{{ __('Save') }}</x-ui.button>
</x-ui.cluster>
</x-ui.cluster>
</div>
```
## Props
- `gap` (string, default `3`) — Gap between items, from the fixed step vocabulary (0-16, or sm/md/lg tokens).
- `align` (string, default `center`) — Cross-axis alignment: start, center, end, baseline, or stretch.
- `justify` (string, default `start`) — Main-axis distribution: start, center, end, between, around, or evenly.
- `wrap` (bool, default `true`) — Whether items wrap onto new lines when they run out of horizontal space.
- `as` (string, default `div`) — HTML tag to render: div, section, nav, header, footer, ul, or ol.
## Use when
- Use to structure hierarchy, spacing, and responsiveness so content is easier to scan and navigate.
- Laying out an inline group of tags, filter chips, buttons, or metadata that should wrap onto new lines as space runs out.
- Needing a fixed gap vocabulary and overflow-safe children (min-width: 0) without hand-writing flex-wrap utilities.
## Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- Building a strict one-dimensional row or column with no wrapping; use stack instead.
- Laying out a two-dimensional grid of cards or tiles; use grid.
## Anti-patterns
- Using visual layout as a substitute for semantic structure
## Rules
- Use the `<brok:cluster>` tag (or `<x-ui.cluster>`) 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/cluster
- Registry JSON (files, props, contract): https://brokui.dev/r/open/cluster.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 |
|---|---|---|---|
| gap | string | 3 | Gap between items, from the fixed step vocabulary (0-16, or sm/md/lg tokens). |
| align | string | center | Cross-axis alignment: start, center, end, baseline, or stretch. |
| justify | string | start | Main-axis distribution: start, center, end, between, around, or evenly. |
| wrap | bool | true | Whether items wrap onto new lines when they run out of horizontal space. |
| as | string | div | HTML tag to render: div, section, nav, header, footer, ul, or ol. |
Slots
default— Inline items laid out in the cluster.
Renders as div, section, nav, header, footer, ul, ol.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Renders a flex row from an approved gap vocabulary, so every gap value maps to a literal Tailwind class Tailwind's JIT can discover.
- Every direct child gets min-width: 0, so long text or media inside an item cannot force the cluster to overflow its container.
- 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.
- Laying out an inline group of tags, filter chips, buttons, or metadata that should wrap onto new lines as space runs out.
- Needing a fixed gap vocabulary and overflow-safe children (min-width: 0) without hand-writing flex-wrap utilities.
Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- Building a strict one-dimensional row or column with no wrapping; use stack instead.
- Laying out a two-dimensional grid of cards or tiles; use grid.
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
- The wrapper carries no semantics of its own beyond the chosen as tag; use a ul/ol with list item children when the cluster represents a list.
- 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([
'gap' => '3',
'align' => 'center',
'justify' => 'start',
'wrap' => true,
'as' => 'div',
])
@php
$allowedTags = ['div', 'section', 'nav', 'header', 'footer', 'ul', 'ol'];
$tag = in_array($as, $allowedTags, true) ? $as : 'div';
$gaps = [
'0' => 'gap-0', '1' => 'gap-1', '2' => 'gap-2', '3' => 'gap-3',
'4' => 'gap-4', '6' => 'gap-6', '8' => 'gap-8', '12' => 'gap-12',
'16' => 'gap-16', 'sm' => 'gap-stack-sm', 'md' => 'gap-stack-md',
'lg' => 'gap-stack-lg',
];
$alignments = [
'start' => 'items-start', 'center' => 'items-center',
'end' => 'items-end', 'baseline' => 'items-baseline',
'stretch' => 'items-stretch',
];
$justifications = [
'start' => 'justify-start', 'center' => 'justify-center',
'end' => 'justify-end', 'between' => 'justify-between',
'around' => 'justify-around', 'evenly' => 'justify-evenly',
];
$gapKey = array_key_exists((string) $gap, $gaps) ? (string) $gap : '3';
$alignKey = array_key_exists($align, $alignments) ? $align : 'center';
$justifyKey = array_key_exists($justify, $justifications) ? $justify : 'start';
$classes = implode(' ', [
'flex max-w-full min-w-0',
$wrap ? 'flex-wrap' : 'flex-nowrap',
$gaps[$gapKey],
$alignments[$alignKey],
$justifications[$justifyKey],
'[&>*]:min-w-0',
]);
@endphp
<{{ $tag }}
data-slot="cluster"
data-gap="{{ $gapKey }}"
{{ $attributes->merge(['class' => $classes]) }}
>{{ $slot }}</{{ $tag }}>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.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