Surface
A constrained panel primitive combining semantic tone, density-aware padding, radius, and elevation tiers.
Preview
A consistent surface
Tone, padding, radius, and shadow use shared tiers.
<x-ui.surface padding="md" class="w-full max-w-md">
<h3 class="font-semibold">{{ __('A consistent surface') }}</h3>
<p class="mt-2 text-sm text-muted-foreground">{{ __('Tone, padding, radius, and shadow use shared tiers.') }}</p>
</x-ui.surface>
Installation
php artisan ui:add surface
Registry contract
php artisan ui:add surface
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/surface.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: Surface (`surface`)
A constrained panel primitive combining semantic tone, density-aware padding, radius, and elevation tiers.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add surface
```
## Usage
```blade
<x-ui.surface padding="md" class="w-full max-w-md">
<h3 class="font-semibold">{{ __('A consistent surface') }}</h3>
<p class="mt-2 text-sm text-muted-foreground">{{ __('Tone, padding, radius, and shadow use shared tiers.') }}</p>
</x-ui.surface>
```
## Props
- `tone` (string, default `card`) — Semantic background/border/foreground combination: surface, elevated, inverse, card, background, muted, popover, or transparent.
- `padding` (string, default `md`) — Inner padding tier: none, sm, md, or lg.
- `radius` (string, default `lg`) — Corner radius tier: none, sm, md, lg, or xl.
- `shadow` (string, default `sm`) — Elevation tier: none, xs, sm, md, or lg.
- `as` (string, default `div`) — HTML tag to render: div, section, main, aside, or article.
## Use when
- Use to structure hierarchy, spacing, and responsiveness so content is easier to scan and navigate.
- Building a custom panel that needs a specific token-backed tone, padding, radius, and shadow combination not covered by card.
- Composing a bespoke container inside a block or page while staying on the semantic token system.
## Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- A standard bordered content card with header/footer parts is enough; use card directly.
- The container is purely structural with no visual tone, padding, or elevation; use stack or grid instead.
## Anti-patterns
- Using visual layout as a substitute for semantic structure
## Rules
- Use the `<brok:surface>` tag (or `<x-ui.surface>`) 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/surface
- Registry JSON (files, props, contract): https://brokui.dev/r/open/surface.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 |
|---|---|---|---|
| tone | string | card | Semantic background/border/foreground combination: surface, elevated, inverse, card, background, muted, popover, or transparent. |
| padding | string | md | Inner padding tier: none, sm, md, or lg. |
| radius | string | lg | Corner radius tier: none, sm, md, lg, or xl. |
| shadow | string | sm | Elevation tier: none, xs, sm, md, or lg. |
| as | string | div | HTML tag to render: div, section, main, aside, or article. |
Slots
default— Panel content.
Renders as div, section, main, aside, article.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Combines tone, padding, radius, and shadow into one class list, all drawn from the shared semantic token scale rather than raw color or shadow utilities.
- 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.
- Building a custom panel that needs a specific token-backed tone, padding, radius, and shadow combination not covered by card.
- Composing a bespoke container inside a block or page while staying on the semantic token system.
Avoid when
- Do not let layout primitives substitute for semantics, headings, or interaction rules users still need.
- A standard bordered content card with header/footer parts is enough; use card directly.
- The container is purely structural with no visual tone, padding, or elevation; use stack or grid 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
- Every tone pairs a background with a matching foreground token, so text placed inside keeps sufficient contrast in both light and dark mode.
- 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([
'tone' => 'card',
'padding' => 'md',
'radius' => 'lg',
'shadow' => 'sm',
'as' => 'div',
])
@php
$allowedTags = ['div', 'section', 'main', 'aside', 'article'];
$tag = in_array($as, $allowedTags, true) ? $as : 'div';
$tones = [
'surface' => 'border border-default bg-surface text-foreground',
'elevated' => 'border border-subtle bg-surface-elevated text-foreground',
'inverse' => 'bg-inverse text-inverse-foreground',
'card' => 'border border-border bg-card text-card-foreground',
'background' => 'border border-border bg-background text-foreground',
'muted' => 'bg-muted text-foreground',
'popover' => 'border border-border bg-popover text-popover-foreground',
'transparent' => 'text-foreground',
];
$paddings = [
'none' => '', 'sm' => 'p-surface-sm',
'md' => 'p-surface-md', 'lg' => 'p-surface-lg',
];
$radii = [
'none' => 'rounded-none', 'sm' => 'rounded-sm',
'md' => 'rounded-md', 'lg' => 'rounded-lg', 'xl' => 'rounded-lg',
];
$shadows = [
'none' => 'shadow-none', 'xs' => 'shadow-xs', 'sm' => 'shadow-sm',
'md' => 'shadow-md', 'lg' => 'shadow-lg',
];
$toneKey = array_key_exists($tone, $tones) ? $tone : 'card';
$paddingKey = array_key_exists($padding, $paddings) ? $padding : 'md';
$radiusKey = array_key_exists($radius, $radii) ? $radius : 'lg';
$shadowKey = array_key_exists($shadow, $shadows) ? $shadow : 'sm';
@endphp
<{{ $tag }}
data-slot="surface"
data-tone="{{ $toneKey }}"
data-padding="{{ $paddingKey }}"
{{ $attributes->merge(['class' => implode(' ', ['min-w-0 max-w-full', $tones[$toneKey], $paddings[$paddingKey], $radii[$radiusKey], $shadows[$shadowKey]])]) }}
>{{ $slot }}</{{ $tag }}>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.5 - 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