Active audits
A Panel titled Active audits holds two rows. Its header ends with a View all chip that opens the audit list.
Components / DataStable
A white group for one theme of related rows or tiles, with an optional header that holds a title and one Chip action.
import { useId, type MouseEventHandler, type ReactNode } from 'react'
import { Chip } from './Chip'
// Nacre Panel: a white group that holds one theme of related rows or wells, with an optional header (a title and one
// Chip action). React plus Tailwind classes only; needs nacre-theme.css and Chip.tsx. One level of grouping:
// ground, panel, well. Keep a well's content flat: never put a bordered box inside a box inside a panel. No motion.
export type PanelAction = {
label: string
href?: string
onClick?: MouseEventHandler<HTMLElement>
}
export type PanelProps = {
/** The heading. With a title the panel is a named region. */
title?: string
/** One quiet action at the end of the header, drawn as a Chip with a chevron. */
action?: PanelAction
/** The heading level, 2 by default. Use 3 or 4 when the panel sits under a screen heading. */
level?: 2 | 3 | 4
/** section (default) is a named region when it has a title; div adds no landmark, for a panel in a busy screen. */
as?: 'section' | 'div'
children: ReactNode
className?: string
}
export function Panel({ title, action, level = 2, as: Root = 'section', children, className = '' }: PanelProps) {
const id = useId()
const named = Root === 'section' && Boolean(title)
const Heading = `h${level}` as 'h2'
return (
<Root
data-part="root"
aria-labelledby={named ? `${id}-title` : undefined}
className={`flex min-w-0 flex-col rounded-xl bg-surface p-1.5 ring-1 ring-line-subtle ${className}`}
>
{(title || action) && (
<div data-part="header" className="flex min-h-12 items-center justify-between gap-3 ps-3 pe-1.5">
{title && <Heading id={`${id}-title`} data-part="title" className="min-w-0 text-[1.125rem] leading-6 font-[600] tracking-[-0.015em] text-fg-strong">{title}</Heading>}
{action && <Chip chevron href={action.href} onClick={action.onClick} className="ms-auto">{action.label}</Chip>}
</div>
)}
{children}
</Root>
)
}
import type { MouseEventHandler, ReactNode } from 'react'
// Nacre Chip: a small pill that starts one quiet action, such as View all in a panel header. React plus Tailwind
// classes only; needs nacre-theme.css. A link when it has an href, otherwise a button. Motion: colour quick 160 out on
// hover; the press scale comes from the Nacre base (pointer only, motion-safe).
export type ChipProps = {
children: ReactNode
/** Shows a chevron after the label, for a chip that goes somewhere. */
chevron?: boolean
/** Makes the chip a link. */
href?: string
onClick?: MouseEventHandler<HTMLElement>
disabled?: boolean
className?: string
}
const base =
'inline-flex h-9 shrink-0 cursor-pointer items-center gap-1 rounded-full bg-sunken px-3.5 text-body font-[600] whitespace-nowrap text-fg ' +
'transition-colors duration-(--nx-dur-quick) ease-out hover:bg-[color-mix(in_oklab,var(--nx-fg)_7%,var(--nx-sunken))] hover:text-fg-strong ' +
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:cursor-not-allowed disabled:text-fg-disabled'
export function Chip({ children, chevron = false, href, onClick, disabled = false, className = '' }: ChipProps) {
const content = (
<>
{children}
{chevron && (
<svg data-part="chevron" aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" className="-me-1 size-4 rtl:scale-x-[-1]">
<path d="M6.5 4l4 4-4 4" />
</svg>
)}
</>
)
if (href && !disabled) {
return <a href={href} data-part="root" data-press="" onClick={onClick} className={`${base} ${className}`}>{content}</a>
}
return <button type="button" data-part="root" disabled={disabled} onClick={onClick} className={`${base} ${className}`}>{content}</button>
}
<section data-part="root" aria-labelledby="_R_0_-title" class="flex min-w-0 flex-col rounded-xl bg-surface p-1.5 ring-1 ring-line-subtle ">
<div data-part="header" class="flex min-h-12 items-center justify-between gap-3 ps-3 pe-1.5">
<h2 id="_R_0_-title" data-part="title" class="min-w-0 text-[1.125rem] leading-6 font-[600] tracking-[-0.015em] text-fg-strong">Active audits</h2>
<button type="button" data-part="root" class="inline-flex h-9 shrink-0 cursor-pointer items-center gap-1 rounded-full bg-sunken px-3.5 text-body font-[600] whitespace-nowrap text-fg transition-colors duration-(--nx-dur-quick) ease-out hover:bg-[color-mix(in_oklab,var(--nx-fg)_7%,var(--nx-sunken))] hover:text-fg-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus disabled:cursor-not-allowed disabled:text-fg-disabled ms-auto">
View all
<svg data-part="chevron" aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="-me-1 size-4 rtl:scale-x-[-1]">
<path d="M6.5 4l4 4-4 4"></path>
</svg>
</button>
</div>
<div data-part="root" data-tint="lime" class="relative isolate flex min-h-36 min-w-0 flex-col overflow-hidden rounded-lg p-4 bg-linear-to-b from-tint-lime to-tint-lime-wash text-tint-lime-ink w-44">
<p data-part="title" class="text-[1.0625rem] leading-6 font-[600] tracking-[-0.015em]">Colour</p>
<p data-part="caption" class="text-label font-[500]">48 tokens</p>
<div data-part="art" aria-hidden="true" class="pointer-events-none absolute grid size-28 place-items-center [&>*]:size-full [&>*]:object-contain -end-1 -bottom-1">
<svg viewBox="0 0 96 96" fill="none" stroke="currentColor" stroke-width="9" stroke-linecap="round">
<circle cx="48" cy="48" r="32" opacity="0.22"></circle>
<path d="M48 16a32 32 0 0 1 30.4 41.8"></path>
</svg>
</div>
</div>
</section>/* The Tailwind theme lines Panel uses. They come from nacre-theme.css (Resources, Tokens), which also defines
the --nx-* values these lines point at. Import that file once; this list is what this component needs from it. */
@theme inline {
--color-surface: var(--nx-surface);
--color-sunken: var(--nx-sunken);
--color-fg-strong: var(--nx-fg-strong);
--color-fg: var(--nx-fg);
--color-fg-disabled: var(--nx-fg-disabled);
--color-line-subtle: var(--nx-line-subtle);
--color-focus: var(--nx-focus);
--text-body: 0.875rem;
--text-body--line-height: 1.25rem;
--text-body--letter-spacing: 0em;
--text-body--font-weight: 400;
--spacing: 0.25rem;
--radius-xl: 1.75rem;
--ease-out: cubic-bezier(.23, 1, .32, 1);
}
A Panel titled Active audits holds two rows. Its header ends with a View all chip that opens the audit list.
A Panel with no header holds a row of two Tiles. The white frame ties them together on the grey page.
DoGroup by ground, panel, well: one level of white, one level of grey inside it.
Don'tNest a bordered box inside a box inside a panel.
DoName the panel with a short title.
Don'tLeave a titled region without a heading; set title so it is a named region.