Skip to content
Nizivo UI

Text

Body, label, numeric and mono text in the Nizivo text styles and text colours, as a paragraph or any element through render.

Server component, no client JS

Import

import { Text } from '@nizivo/react/text';

// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/text.css';

Static or interactive

Server. It ships no client JavaScript when a Server Component renders it, in every Next.js build mode; its code is bundled only when a client component (a 'use client' file) imports it. How to choose.

In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.

Tones

tone="accent" is deprecated: it paints --nz-text-brand, exactly as tone="brand" does, since Figma has no accent text for page surfaces (M38). Use tone="brand". It keeps working, with no visual change; its removal is deferred to 1.0, or to when Figma adds an accent text for page surfaces. Accent text on bg/inverse is --nz-text-inverse-accent. Card's and KpiTile's tone="accent", a surface rather than a text colour, is not deprecated.

Examples

Basic

Shown on product pages and checkout.

No action needed.

₹4,82,190Updated 2 min agoSKU-1040
import type { JSX } from 'react';
import { Text } from '@nizivo/react/text';

export function TextExample(): JSX.Element {
  return (
    <div>
      <Text>Shown on product pages and checkout.</Text>
      <Text variant="body-m" tone="secondary">
        No action needed.
      </Text>
      <Text variant="numeric-kpi" tone="primary" render={<span />}>
        ₹4,82,190
      </Text>
      <Text variant="label-s" tone="tertiary" render={<span />}>
        Updated 2 min ago
      </Text>
      <Text variant="mono-m" tone="secondary" render={<code />}>
        SKU-1040
      </Text>
    </div>
  );
}

Props

Server component Renders data-slot="text" with the class nz-text. Props: TextProps. Source: src/text/text.tsx.

NameTypeDefaultDescription
renderRenderProp<TextState>–

Another element or component, for example render={<span />} or render={<label htmlFor="sku" />}.

toneTextTone
"primary""secondary""tertiary""disabled""inverse""on-brand""on-accent""on-critical""brand""accent""success""warning""critical""info"
–

A text/* colour. Absent, the colour is inherited from the surface. Deprecated value: 'accent', which paints --nz-text-brand; use 'brand' (M42; removal deferred to 1.0).

variantTextVariant
"display-l""display-m""heading-h1""heading-h2""heading-h3""heading-h4""body-l""body-m""body-m-strong""body-s""label-l""label-m""label-m-strong""label-s""numeric-display""numeric-kpi""numeric-l""numeric-m""mono-m""mono-m-strong"
'body-m'

The text style. 12 px exists only as body-s and label-s (§15.1).

  • Also takes every attribute of <p>. (ComponentPropsWithRef<"p">)

render takes an element, or, in client code, a function of the props and this state (TextState):

NameTypeDefaultDescription
tonerequiredTextTone | undefined
"primary""secondary""tertiary""disabled""inverse""on-brand""on-accent""on-critical""brand""accent""success""warning""critical""info"
–
variantrequiredTextVariant
"display-l""display-m""heading-h1""heading-h2""heading-h3""heading-h4""body-l""body-m""body-m-strong""body-s""label-l""label-m""label-m-strong""label-s""numeric-display""numeric-kpi""numeric-l""numeric-m""mono-m""mono-m-strong"
–

Other exports

TextProps type

import type { TextProps } from '@nizivo/react/text'

The props of Text, listed above.

TextState type

import type { TextState } from '@nizivo/react/text'

The render state of Text, listed above.

TextTone type

import type { TextTone } from '@nizivo/react/text'

The text/* colour tokens. accent paints --nz-text-brand, since Figma has no accent text for page surfaces (M38; --nz-text-inverse-accent is for bg/inverse).

Deprecated: 'accent', which looks exactly like 'brand'; use 'brand'. It keeps working; its removal is deferred to 1.0, or to when Figma adds an accent text for page surfaces (M42). TypeScript cannot deprecate one member of a union type, so this note is the marker. Card's and KpiTile's tone="accent", a surface, are not deprecated.

type TextTone = "primary" | "secondary" | "tertiary" | "disabled" | "inverse" | "on-brand" | "on-accent" | "on-critical" | "brand" | "accent" | "success" | "warning" | "critical" | "info"

TextVariant type

import type { TextVariant } from '@nizivo/react/text'

The Figma text styles as lowercase names (Nizivo/Label/M → label-m), plus the 12 px proposals.

type TextVariant = "display-l" | "display-m" | "heading-h1" | "heading-h2" | "heading-h3" | "heading-h4" | "body-l" | "body-m" | "body-m-strong" | "body-s" | "label-l" | "label-m" | "label-m-strong" | "label-s" | "numeric-display" | "numeric-kpi" | "numeric-l" | "numeric-m" | "mono-m" | "mono-m-strong"

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
text
.nz-text
Text
root (takes render)
  • data-tone: "primary""secondary""tertiary""disabled""inverse""on-brand""on-accent""on-critical""brand""accent""success""warning""critical""info" ← tone
    The tone prop; values in each component manifest
  • data-variant: "display-l""display-m""heading-h1""heading-h2""heading-h3""heading-h4""body-l""body-m""body-m-strong""body-s""label-l""label-m""label-m-strong""label-s""numeric-display""numeric-kpi""numeric-l""numeric-m""mono-m""mono-m-strong" ← variant
    The variant prop; values are the lowercase Figma names in each component manifest

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

Tokens this stylesheet reads (53)

--nz-font-body-l, --nz-font-body-m, --nz-font-body-m-strong, --nz-font-body-s, --nz-font-display-l, --nz-font-display-m, --nz-font-heading-h1, --nz-font-heading-h2, --nz-font-heading-h3, --nz-font-heading-h4, --nz-font-label-l, --nz-font-label-m, --nz-font-label-m-strong, --nz-font-label-s, --nz-font-mono-m, --nz-font-mono-m-strong, --nz-font-numeric-display, --nz-font-numeric-kpi, --nz-font-numeric-l, --nz-font-numeric-m, --nz-text-brand, --nz-text-critical, --nz-text-disabled, --nz-text-info, --nz-text-inverse, --nz-text-on-accent, --nz-text-on-brand, --nz-text-on-critical, --nz-text-primary, --nz-text-secondary, --nz-text-success, --nz-text-tertiary, --nz-text-warning, --nz-tracking-body-l, --nz-tracking-body-m, --nz-tracking-body-m-strong, --nz-tracking-body-s, --nz-tracking-display-l, --nz-tracking-display-m, --nz-tracking-heading-h1, --nz-tracking-heading-h2, --nz-tracking-heading-h3, --nz-tracking-heading-h4, --nz-tracking-label-l, --nz-tracking-label-m, --nz-tracking-label-m-strong, --nz-tracking-label-s, --nz-tracking-mono-m, --nz-tracking-mono-m-strong, --nz-tracking-numeric-display, --nz-tracking-numeric-kpi, --nz-tracking-numeric-l, --nz-tracking-numeric-m

Accessibility

Nothing in this component takes focus or keyboard input.

Keyboard

None.

Figma

Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.

  • Canonical: none
  • Ghost masters: none

On this page