Components
DocsCard
Unstable: an entry point into an area of documentation, an icon, the title, what is there and a real count, as one link. Import it from @nizivo/react/unstable/docs-card.
Examples
Basic
An entry point on a docs home page: one link, named by its title.
import type { JSX } from 'react';
import { DocsCard } from '@nizivo/react/unstable/docs-card';
/** Stand-in for `@nizivo/icons` Layers (a Lucide stroke). */
function Layers(): JSX.Element {
return (
<svg
viewBox="0 0 24 24"
width="1em"
height="1em"
fill="none"
stroke="currentColor"
strokeWidth={1.92}
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" />
<path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" />
<path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />
</svg>
);
}
export function DocsCardExample(): JSX.Element {
return (
<div style={{ inlineSize: 300 }}>
<DocsCard
href="/docs/components/"
icon={<Layers />}
title="Components"
description="Every control with props, states, code and keyboard notes."
meta="114 components"
/>
</div>
);
}
Import
import { DocsCard } from '@nizivo/react/unstable/docs-card';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/docs-card.css';Static or interactive
Server. No client JavaScript: the whole card is one link. How to choose.
Content
title names the area and the link, description says what is there, meta gives a real count
("114 components") and icon fills the tile. Keep counts true: generate them, never type them.
Props
Server component Renders data-slot="docs-card" with the class nz-docs-card. Props: DocsCardProps. Source: src/unstable/docs-card/docs-card.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
description | ReactNode | – | What is there: "Every control with props, states, code and keyboard notes." |
icon | ReactNode | – | A 20 px glyph for the tile, such as one from |
meta | ReactNode | – | A real count: "114 components". |
render | RenderProp<Record<string, never>> | – | Must render an |
titlerequired | ReactNode | – | The area: "Components". |
- Also takes every attribute of
<a>excepttitle. (Omit<ComponentPropsWithRef<"a">, "title">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
DocsCardPropstypeimport type { DocsCardProps } from '@nizivo/react/unstable/docs-card'The props of
DocsCard, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
docs-card.nz-docs-card | DocsCardroot (takes render); interactive, focus: self | none |
docs-card-description.nz-docs-card-description | DocsCardinner element (CSS only) | none |
docs-card-meta.nz-docs-card-meta | DocsCardinner element (CSS only) | none |
docs-card-title.nz-docs-card-title | DocsCardinner element (CSS only) | none |
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-docs-card, .nz-docs-card-arrow, .nz-docs-card-description, .nz-docs-card-icon, .nz-docs-card-meta, .nz-docs-card-title, .nz-docs-card-top.
Tokens this stylesheet reads (23)
--nz-bg-brand-subtle, --nz-bg-surface, --nz-border-strong, --nz-border-subtle, --nz-border-width-default, --nz-duration-fast, --nz-easing-standard, --nz-font-body-m, --nz-font-heading-h3, --nz-font-label-s, --nz-icon-brand, --nz-icon-secondary, --nz-radius-md, --nz-radius-xl, --nz-size-icon-md, --nz-space-1, --nz-space-10, --nz-space-3, --nz-space-6, --nz-text-brand, --nz-text-primary, --nz-text-secondary, --nz-tracking-heading-h3
Accessibility
These parts are interactive. Each gets the focus outline and touch-action rule from @nizivo/react/css/base.css (the nz.base layer), so the floor survives a restyle:
docs-card: draws the focus outline itself on keyboard focus.
Keyboard
To be written.
Dialog
A modal dialog or alert dialog with a trigger, title, description, body, footer and close parts. Focus moves in on open and returns to the trigger on close.
Drawer
A modal panel that slides in from an edge of the viewport, for details or a task beside the page, with a header, a body that scrolls and a footer. side="bottom" is a bottom sheet.