Skip to content
Get started

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.

Server component, no client JSUnstable

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.

NameTypeDefaultDescription
descriptionReactNode–

What is there: "Every control with props, states, code and keyboard notes."

iconReactNode–

A 20 px glyph for the tile, such as one from @nizivo/icons.

metaReactNode–

A real count: "114 components".

renderRenderProp<Record<string, never>>–

Must render an <a>, or a router link that renders one.

titlerequiredReactNode–

The area: "Components".

  • Also takes every attribute of <a> except title. (Omit<ComponentPropsWithRef<"a">, "title">)

render takes an element, or, in client code, a function of the props and no state.

Other exports

DocsCardProps type

import 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.

SlotRendered byData attributes
docs-card
.nz-docs-card
DocsCard
root (takes render); interactive, focus: self
none
docs-card-description
.nz-docs-card-description
DocsCard
inner element (CSS only)
none
docs-card-meta
.nz-docs-card-meta
DocsCard
inner element (CSS only)
none
docs-card-title
.nz-docs-card-title
DocsCard
inner 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.

On this page