Surface
A passive visual surface container with standardized variant, radius, border, elevation, and state props.
A passive visual container that standardizes surface variants, corner radius, borders, elevation, and visual interaction states while letting styled components own the actual paint.
Preview
Section titled “Preview”The preview passes explicit passive visual states to illustrate surface presentation without adding button or focus behavior.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (CLI target: base-surface). Import surfaceRoot (along with SurfaceRootProps, SurfaceRootExposes, asSurfaceRoot, and SurfaceRootAsHookContract) from @proto.ui/prototypes-base/surface or the package root.
import * as React from 'react';import { createReactAdapter } from '@proto.ui/adapter-react';import { surfaceRoot } from '@proto.ui/prototypes-base/surface';
const Surface = createReactAdapter(React)(surfaceRoot);
export function Summary() { return ( <Surface variant="muted" radius="md" border="none"> <div style={{ padding: '1rem' }}>Saved locally</div> </Surface> );}Passive visual inputs
Section titled “Passive visual inputs”- Pass
hovered,focusVisible,pressed, andcurrentfrom an enclosing interactive component.Surfaceitself adds no event listeners, tab stops, accessible roles, or activation handlers. - Removing a prop restores its default value. Content layout and padding belong to the caller; set
tone="inherit"on nested styledTextelements when they should inherit the enclosingSurfaceforeground color. - When you need real button or link semantics, use
Buttonor a native<a>element rather than attaching click handlers toSurface.
Following an existing Transition
Section titled “Following an existing Transition”- Set
fade={true}to maptransitionState(supplied by Transition) to opacity in styled components:closedandleavingmap to0, whileenteringandenteredmap to1. - On Web, pass a finite non-negative duration via the
--pui-surface-transition-durationCSS variable (defaults to0ms). variant="scrim"applies a standard backdrop dimming surface. Zero opacity is purely visual; presence, inertness, and focus management remain with the enclosingDialogorTransition.
| Prop | Type | Default |
|---|---|---|
variant | 'transparent' 'outline' 'secondary' 'muted' 'accent' 'solid' 'scrim' | outline |
radius | 'default' 'none' 'sm' 'md' 'lg' 'xl' 'full' | default |
border | 'all' 'bottom' 'none' | all |
elevation | 'none' 'raised' | none |
transitionState | 'closed' 'entering' 'entered' 'leaving' | entered |
fade | boolean | false |
hovered | boolean | false |
focusVisible | boolean | false |
pressed | boolean | false |
current | boolean | false |