Skip to content
Nizivo UI

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.

Server component, no client JS

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.

Store hours

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.

New collection

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.

NameTypeDefaultDescription
materialSurfaceMaterial
"solid""glass"
'solid'

solid: bg/surface. glass: bg/surface at 72 % over a blurred backdrop, with a soft shadow; opaque where the backdrop cannot be blurred, under reduced transparency and in forced colours.

renderRenderProp<SurfaceState>–

Any element: a <section>, a <nav>, a <header>.

  • 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):

NameTypeDefaultDescription
materialrequiredSurfaceMaterial
"solid""glass"
–

Other exports

SurfaceMaterial type

import type { SurfaceMaterial } from '@nizivo/react/surface'

type SurfaceMaterial = "solid" | "glass"

SurfaceProps type

import type { SurfaceProps } from '@nizivo/react/surface'

The props of Surface, listed above.

SurfaceState type

import 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.

SlotRendered byData attributes
surface
.nz-surface
Surface
root (takes render)
  • data-material: "solid""glass" ← material
    The panel's material: opaque, or translucent over a blurred backdrop

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

On this page