View all
A Panel lists three active audits. A Chip with a chevron at the end of its header opens the full list.
Components / ActionsStable
A small pill that starts one quiet action, such as View all at the end of a panel header or Edit beside a section title.
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>
}
<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 ">
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>/* The Tailwind theme lines Chip 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-sunken: var(--nx-sunken);
--color-fg-strong: var(--nx-fg-strong);
--color-fg: var(--nx-fg);
--color-fg-disabled: var(--nx-fg-disabled);
--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;
--ease-out: cubic-bezier(.23, 1, .32, 1);
}
A Panel lists three active audits. A Chip with a chevron at the end of its header opens the full list.
The Brand section of a token page ends its header with an Edit chip that opens the editing drawer.
DoName the action in one or two words: View all, Edit.
Don'tWrite a sentence, or repeat the panel title inside the chip.
DoUse one chip per header.
Don'tLine up several chips; use a Button group or a menu.