Patterns
Tiled, themeable background layers — dots, grid lines, circuit traces or film grain.
Preview
Grid Pattern
A themeable tiled line grid that sits quietly behind your content and fades toward the edges.
<div class="relative h-64 w-full overflow-hidden rounded-xl border border-border bg-card">
<x-ui.grid-pattern :fade="true" class="text-border" />
<div class="relative flex h-full flex-col items-center justify-center gap-2 px-6 text-center">
<h3 class="text-xl font-semibold text-foreground">Grid Pattern</h3>
<p class="max-w-sm text-sm text-muted-foreground">
A themeable tiled line grid that sits quietly behind your content and fades toward the edges.
</p>
</div>
</div>
Installation
php artisan ui:add grid-pattern
Registry contract
php artisan ui:add grid-pattern
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/grid-pattern.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: Grid Pattern (`grid-pattern`)
A tiled, themeable grid-lines background layer with adjustable gap, line width and optional edge fade.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add grid-pattern
```
## Usage
```blade
<div class="relative h-64 w-full overflow-hidden rounded-xl border border-border bg-card">
<x-ui.grid-pattern :fade="true" class="text-border" />
<div class="relative flex h-full flex-col items-center justify-center gap-2 px-6 text-center">
<h3 class="text-xl font-semibold text-foreground">Grid Pattern</h3>
<p class="max-w-sm text-sm text-muted-foreground">
A themeable tiled line grid that sits quietly behind your content and fades toward the edges.
</p>
</div>
</div>
```
## Props
- `gap` (int, default `32`) — Distance between grid lines, in pixels.
- `lineWidth` (int, default `1`) — Line thickness, in pixels.
- `fade` (bool, default `false`) — Fades the pattern toward the edges with a radial mask when true.
## Use when
- Use only when visual expression supports storytelling, brand differentiation, or a clear showcase moment.
- Adding a subtle, tileable line-grid texture behind content.
- Wanting a background pattern that themes automatically through a text-* colour utility.
## Avoid when
- Do not place heavy effects in task-dense workflows where clarity, speed, and readability matter more.
- Wanting dot-based texture instead of lines; use dot-pattern.
- Wanting an animated or circuitry motif; use circuit-board instead.
## Anti-patterns
- Heavy effects in forms or task-dense workflows
- Motion that interferes with reading or focus
## Rules
- Use the `<brok:grid-pattern>` tag (or `<x-ui.grid-pattern>`) 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/grid-pattern
- Registry JSON (files, props, contract): https://brokui.dev/r/open/grid-pattern.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 | int | 32 | Distance between grid lines, in pixels. |
| lineWidth | int | 1 | Line thickness, in pixels. |
| fade | bool | false | Fades the pattern toward the edges with a radial mask when true. |
Slots
default— Not used by this component; present for attribute-bag compatibility.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Paints two repeating linear-gradient tiles, one vertical and one horizontal, sized by gap and lineWidth; fade adds a radial mask so the grid fades out toward the edges.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Support brand expression or a showcase moment.
Use when
- Use only when visual expression supports storytelling, brand differentiation, or a clear showcase moment.
- Adding a subtle, tileable line-grid texture behind content.
- Wanting a background pattern that themes automatically through a text-* colour utility.
Avoid when
- Do not place heavy effects in task-dense workflows where clarity, speed, and readability matter more.
- Wanting dot-based texture instead of lines; use dot-pattern.
- Wanting an animated or circuitry motif; use circuit-board instead.
Use instead
- Static content-first presentation
Anti-patterns
- Heavy effects in forms or task-dense workflows
- Motion that interferes with reading or focus
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- No component-owned keyboard interaction; native element behavior applies.
- Focus
none
- The layer is aria-hidden and pointer-events-none, purely decorative, and static — there is no motion to reduce.
- 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' => 32,
'lineWidth' => 1,
'fade' => false,
])
@php
// A tiled grid of thin lines built from two linear-gradients (one vertical,
// one horizontal) repeated over a `gap`×`gap` tile. Lines use `currentColor`
// so a `text-*` token on the element (default `text-border`) themes them.
$gapPx = (int) $gap;
$lw = (float) $lineWidth;
$vertical = 'linear-gradient(to right, currentColor '.$lw.'px, transparent '.$lw.'px)';
$horizontal = 'linear-gradient(to bottom, currentColor '.$lw.'px, transparent '.$lw.'px)';
$bg = $vertical.', '.$horizontal;
// Optional edge fade: a radial mask keeps the centre fully opaque and fades
// the grid toward the edges so the layer melts into its container.
$fadeStyle = $fade
? 'mask-image:radial-gradient(ellipse at center, black 50%, transparent 100%);'
.'-webkit-mask-image:radial-gradient(ellipse at center, black 50%, transparent 100%);'
: '';
@endphp
<div
data-slot="grid-pattern"
aria-hidden="true"
style="background-image:{{ $bg }}; background-size:{{ $gapPx }}px {{ $gapPx }}px; {{ $fadeStyle }}"
{{ $attributes->merge(['class' => 'pointer-events-none absolute inset-0 text-border']) }}
></div>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.0.3 - 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