@hex-core/preview

DemoSurface wrapper for showcasing components on flat-white pages.

Install

Version 0.2.0Tool / dlx invocation
bash
pnpm add @hex-core/preview

What it does

`@hex-core/preview` is a tiny demo-surface helper. It exports `<DemoSurface>`, the elevated container the official docs site uses to wrap component previews so Outline / Secondary buttons read against an off-white background instead of a flat-white page.

Hex UI's tokens are deliberately subtle — `--border` and `--input` sit close to `--card` to avoid heavy mid-grays. That choice looks great on already-elevated surfaces (Card, Popover, Dialog) but washes out on a plain page background. `<DemoSurface>` reproduces the official preview's elevation in one component so consumers' showcase pages match the docs site visually.

This package is optional. If you're building a marketing site or a production app, you don't need it. If you're authoring component demos for your own design system or internal docs, drop a `<DemoSurface>` around each one and you're done.

Public API

DemoSurface

ts
import { DemoSurface } from "@hex-core/preview";

interface DemoSurfaceProps extends React.HTMLAttributes<HTMLDivElement> {
	minHeight?: string;
}

Elevated div that mimics the docs-site preview wrapper. Pass any standard div attributes — `id`, `data-*`, `className` (merged with Tailwind). `minHeight` defaults to a comfortable showcase height; override when wrapping tall demos.

tsx
import { DemoSurface } from "@hex-core/preview";
import { Button } from "@hex-core/components";

export function ButtonShowcase() {
	return (
		<DemoSurface>
			<Button variant="outline">Visible against the surface</Button>
		</DemoSurface>
	);
}

Workflows

Wrap an entire showcase grid

One surface around the grid is plenty — no need to nest one per cell. The grid inherits the elevation from its parent.

tsx
import { DemoSurface } from "@hex-core/preview";
import { Button, Grid } from "@hex-core/components";

export function VariantShowcase() {
	return (
		<DemoSurface minHeight="240px">
			<Grid cols={3} gap="3">
				<Button>Default</Button>
				<Button variant="outline">Outline</Button>
				<Button variant="secondary">Secondary</Button>
			</Grid>
		</DemoSurface>
	);
}

Compatibility

  • Peer deps: `react ^18 || ^19`, `react-dom ^18 || ^19`.
  • Assumes the consumer's app already loads the Hex UI token CSS — utilities like `bg-muted` need to resolve.
  • Pure React component; no Radix dependency, no portal usage.

See also