Panel
A report surface: one card whose sections stack on hairlines. Put stats, a chart and a table in one Panel and it reads as one document.
Preview
Weekly report
Nov 21 – 27
Sections split on hairlines instead of nesting more cards.
Highlights
3 items
- Checkout latency down to 210 ms
- New onboarding flow shipped
- Two incidents, both resolved
Install
npx shadcn@latest add @dxbh-ui/panel
Add the @dxbh-ui registry to components.json once:
{
"registries": {
"@dxbh-ui": "https://ui.dxbh.dev/r/{name}.json"
}
}Usage
"use client";
import { Panel, PanelHeading, PanelSection } from "@/components/ui/panel/panel";
export default function PanelDemo() {
return (
<Panel className="w-full max-w-md">
<PanelSection>
<PanelHeading title="Weekly report" meta="Nov 21 – 27" />
<p className="mt-2 text-sm text-muted-foreground">Sections split on hairlines instead of nesting more cards.</p>
</PanelSection>
<PanelSection>
<PanelHeading title="Highlights" meta="3 items" as="h4" />
<ul className="mt-2 grid gap-1 text-sm text-foreground/80">
<li>Checkout latency down to 210 ms</li>
<li>New onboarding flow shipped</li>
<li>Two incidents, both resolved</li>
</ul>
</PanelSection>
</Panel>
);
}Props
| Prop | Type | Default |
|---|---|---|
PanelThe card. | HTMLAttributes<HTMLDivElement> | — |
PanelSection.flushDrop the padding for children that pad themselves. | boolean | false |
PanelHeading.title*Section title. | ReactNode | — |
PanelHeading.metaQuiet trailing context: a range, a note, an action. | ReactNode | — |
PanelHeading.asHeading element. | "p" | "h2" | "h3" | "h4" | "h3" |
Polish
- Brand surface and rule tokens replaced with the shadcn card and border colours.
- Hairlines between sections instead of nested cards; the first section has none.
- Heading defaults to an h3 so the outline stays meaningful; pass as to change it.
- Section padding tightens below the sm breakpoint so nothing scrolls at 390px.
Source
import type { HTMLAttributes, ReactNode } from "react";
import { cn } from "@/lib/utils";
/**
* A report surface: one card whose sections stack and split on hairlines
* instead of nesting more cards. Put a StatStrip, a TrendChart and a
* DataTable in one Panel and it reads as one document.
*/
export function Panel({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
return (
<div
data-slot="panel"
className={cn("overflow-hidden rounded-xl border bg-card text-card-foreground", className)}
{...props}
/>
);
}
export type PanelSectionProps = HTMLAttributes<HTMLDivElement> & {
/** No padding, for children that pad themselves (a StatStrip, a full-bleed table). */
flush?: boolean;
};
/** A band inside a Panel. Every band after the first gets a hairline. */
export function PanelSection({ className, flush = false, ...props }: PanelSectionProps) {
return (
<div
data-slot="panel-section"
className={cn("border-t first:border-t-0", !flush && "px-5 py-4 sm:px-6 sm:py-5", className)}
{...props}
/>
);
}
export type PanelHeadingProps = {
title: ReactNode;
/** Quiet trailing context: a date range, "sample data", an action. */
meta?: ReactNode;
as?: "p" | "h2" | "h3" | "h4";
className?: string;
};
/** Title on the left, quiet meta on the right. The heading every chart and table shares. */
export function PanelHeading({ title, meta, as: Tag = "h3", className }: PanelHeadingProps) {
return (
<div data-slot="panel-heading" className={cn("flex items-baseline justify-between gap-4", className)}>
<Tag className="min-w-0 truncate text-sm font-medium text-foreground">{title}</Tag>
{meta ? <div className="shrink-0 text-xs text-muted-foreground tabular-nums">{meta}</div> : null}
</div>
);
}Extracted from Vesrelle/components/data/panel.tsx at 4619651.