Surface
A panel of the page's surface colour, solid or glass. Glass is the surface at 72 % over a blurred backdrop, for a panel over a photo, a shader or a busy page, and it stays opaque wherever the blur is not available.
Import
import { Surface } from '@nizivo/react/surface';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/surface.css';Static or interactive
Server. No client JavaScript: it is a styled element. How to choose.
Solid or glass
material="solid" (the default) paints bg/surface with a hairline border and radius/xl.
material="glass" is Figma's Surface/Glass style: bg/surface at 72 % with a 24 px blur of
whatever is behind it, and a soft shadow, as on the floating navbar over a shader hero. Put it over
an image or colour, as the design says ("always on a tinted card, never on white"); over a plain
white page it looks like a solid panel.
render makes it any element: render={<nav aria-label="Main" />} for a navbar,
render={<section />} for a card.
Where glass stays opaque
The text on glass keeps the surface's contrast because the panel falls back to solid whenever the blur cannot happen or should not:
- in browsers without
backdrop-filter(Safari before 18, the floor's Safari 17.5); - when the reader asks for reduced transparency (
prefers-reduced-transparency: reduce); - in forced colours, where it is the system's
Canvas.
Styling
Surface has no public hooks (--nz-surface-* names design tokens), so set its padding, radius or
border with your own class or style.
Examples
Basic
The default solid panel: bg/surface, a hairline and radius/xl.
Mon–Sat, 9:00–18:00
import type { JSX } from 'react';
import { Surface } from '@nizivo/react/surface';
export function SurfaceExample(): JSX.Element {
return (
<Surface style={{ maxInlineSize: 320, padding: 20 }}>
<strong>Store hours</strong>
<p style={{ margin: '4px 0 0' }}>Mon–Sat, 9:00–18:00</p>
</Surface>
);
}
Glass
Glass over an image: bg/surface at 72 % with the backdrop blurred behind it, as Figma's floating navbar and the Lab's Glass card. Opaque where the backdrop cannot be blurred.
Stoneware in five glazes, from Friday.
import type { JSX } from 'react';
import { Surface } from '@nizivo/react/surface';
export function SurfaceGlassExample(): JSX.Element {
return (
<div
style={{
display: 'grid',
placeItems: 'center',
inlineSize: 360,
blockSize: 220,
borderRadius: 16,
background:
'radial-gradient(circle at 25% 30%, #4c9e71 0 22%, transparent 23%), radial-gradient(circle at 75% 70%, #c9b79c 0 26%, transparent 27%), linear-gradient(135deg, #1a573a, #8a6e4b)',
}}
>
<Surface material="glass" style={{ inlineSize: 260, padding: 20 }}>
<strong>New collection</strong>
<p style={{ margin: '4px 0 0' }}>Stoneware in five glazes, from Friday.</p>
</Surface>
</div>
);
}
Props
Server component Renders data-slot="surface" with the class nz-surface. Props: SurfaceProps. Source: src/surface/surface.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
material | SurfaceMaterial"solid""glass" | 'solid' |
|
render | RenderProp<SurfaceState> | – | Any element: a |
- Also takes every attribute of
<div>. (ComponentPropsWithRef<"div">)
render takes an element, or, in client code, a function of the props and this state (SurfaceState):
| Name | Type | Default | Description |
|---|---|---|---|
materialrequired | SurfaceMaterial"solid""glass" | – |
Other exports
SurfaceMaterialtypeimport type { SurfaceMaterial } from '@nizivo/react/surface'type SurfaceMaterial = "solid" | "glass"SurfacePropstypeimport type { SurfaceProps } from '@nizivo/react/surface'The props of
Surface, listed above.SurfaceStatetypeimport type { SurfaceState } from '@nizivo/react/surface'The render state of
Surface, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
surface.nz-surface | Surfaceroot (takes render) |
|
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
This stylesheet reads no public hook.
Layers: nz.components. Classes: .nz-surface.
Tokens this stylesheet reads (6)
--nz-bg-surface, --nz-border-subtle, --nz-border-width-default, --nz-elevation-3, --nz-radius-xl, --nz-text-primary
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: none
- Ghost masters: none
StickyBar
A bar of actions that sticks to the bottom of the viewport while its section scrolls, above the device's home indicator and the shell's bottom tab bar.
Switch
An on or off setting that applies at once, drawn as a track and thumb. A native checkbox with role switch, so it submits with the form before hydration.