Todae

Todae

Text

Body text draws at text.font.size. The default equals foundation font.size.3. Text has no size prop. Todae does not ship a text size scale.

On this page

To change one text, set --todae-text-font-size on the element or on an ancestor with no [data-appearance], [data-density] or [data-motion] element and no scoped theme root between them. A ThemeProvider, a DensityProvider or a MotionProvider carries one of those attributes. Such an element, or a scoped theme root, in between declares the token again and drops the ancestor's value. To change body text across a product, set text.font.size in your theme or in ThemeProvider overrides. For a one-off size, set font-size from a font.size.* variable (--todae-font-size-*) in your own CSS. A rule outside the todae.components layer wins over the size Text sets.

A heading's as renders that element, and the element draws at text.h1.font.size through text.h6.font.size. The defaults follow foundation font.size.6, font.size.5, font.size.4, body text.font.size, body text.font.size, and font.size.2. h4 and h5 follow the body token, and a theme can set either one on its own. variant="label" is the role for eyebrows and metadata, described under Label below.

The typeface lives in text.font.family, which reads font.family.sans. Todae does not set font-family from it on body text and headings; apply var(--todae-text-font-family) where you want it. The label role sets its own, as Label below says.

Server Components can import it from @tounsoo/todae/text. That entry has no 'use client' and no hooks; the main @tounsoo/todae entry is a client module.

import { Text } from '@tounsoo/todae/text';

export default function TextTones() {
  return (
    <>
      <Text.Root tone="muted">Muted body</Text.Root>
      <Text.Root>Medium default</Text.Root>
      <Text.Root tone="accent" weight="bold">
        Accent, bold
      </Text.Root>
    </>
  );
}

Muted body

Medium default

Accent, bold

tone="accent" follows color.accent.default. Todae's accent is neutral ink, so accent text looks like default text until a theme or company token package sets a brand accent.

Headings

as="h1" through as="h6" render a heading. The element draws at text.hN.font.size, with bold weight and text.leading.tight, and balances its line breaks. Pick the level for the outline. An h2 keeps text.h2.font.size. To draw that heading smaller, set font-size on the element, or override that level's token. Do not pick a lower level for the look.

<Text.Root as="h2" className="section-title">
  Still an h2
</Text.Root>
.section-title {
  font-size: var(--todae-font-size-3);
}
import { Text } from '@tounsoo/todae/text';

export default function TextHeadings() {
  return (
    <>
      <Text.Root as="h1">Heading 1</Text.Root>
      <Text.Root as="h2">Heading 2</Text.Root>
      <Text.Root as="h3">Heading 3</Text.Root>
      <Text.Root as="h4">Heading 4</Text.Root>
      <Text.Root as="h5">Heading 5</Text.Root>
      <Text.Root as="h6">Heading 6</Text.Root>
    </>
  );
}

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Label

variant="label" is the role for short text over or beside other text: an eyebrow over a heading, a kicker, a section number or a date. It reads text.label.* for its family, size, weight, leading, letter spacing, case and color, so each company decides how its labels look, such as mono, uppercase and tracked. Graphite leaves them plain: font.size.1, text.weight.medium, tight leading, text.fg.muted, no letter spacing and no change of case.

Todae applies text.label.font.family, unlike text.font.family. It reads text.font.family, so a theme that sets one typeface for text sets the label's too, and a theme that sets text.label.font.family to font.family.mono changes only the labels. A product whose text font comes from its own CSS rather than var(--todae-text-font-family) sets text.label.font.family to that font as well, or its labels show font.family.sans.

A tone or weight you give wins over the label's own color and weight.

import { Text } from '@tounsoo/todae/text';

export default function TextLabel() {
  return (
    <hgroup>
      <Text.Root variant="label">Release notes</Text.Root>
      <Text.Root as="h2">
        What changed in 0.4
      </Text.Root>
    </hgroup>
  );
}

Release notes

What changed in 0.4

A company token package sets the look in its own contract set, as the Fernway example does:

{
  "text": {
    "label": {
      "font": {
        "family": { "$type": "fontFamily", "$value": { "$ref": "#/font/family/mono/$value" } },
        "letter-spacing": { "$type": "dimension", "$value": { "value": 0.06, "unit": "rem" } },
        "text-transform": { "$type": "textTransform", "$value": "uppercase" }
      }
    }
  }
}

Lines

lines clamps the text to that many lines and ends the last one in an ellipsis. A word longer than the line, such as a file name, breaks so it ends in the ellipsis too. The element becomes a block, so it takes the width its parent gives it; in a flex row it can shrink below its text.

When the text is cut, Text.Root from @tounsoo/todae shows the whole text in a tooltip on hover, and on keyboard focus of the text or of a link, row or menu item around it. One that holds several cut texts shows the first one's tooltip. Clamping changes only what is painted, so screen readers read the whole text and the tooltip is hidden from them. While it shows, the tooltip is an element right after the text, so it can change what a selector such as :last-child matches. Escape closes it first. tooltip={false} turns it off. @tounsoo/todae/text clamps the same way but draws no tooltip, since that needs a client component.

import { Stack, Text } from '@tounsoo/todae';

// The main entry, not @tounsoo/todae/text, so the cut text shows its tooltip.
export default function TextLines() {
  return (
    <Stack.Root gap="condensed" style={{ inlineSize: '100%', maxInlineSize: '16rem' }}>
      <Text.Root lines={1} weight="medium">
        quarterly-revenue-report-northern-region-final.pdf
      </Text.Root>
      <Text.Root lines={2} tone="muted">
        Every branch office&apos;s numbers for July through September, with notes from each regional lead and the
        forecast for the next quarter.
      </Text.Root>
    </Stack.Root>
  );
}

quarterly-revenue-report-northern-region-final.pdf

Every branch office's numbers for July through September, with notes from each regional lead and the forecast for the next quarter.

Accessible composition

Todae handles: The element. as picks p (the default), span, strong or h1 to h6, and the element keeps its native meaning. weight changes only the look, and a heading's level picks text.hN.font.size. An h2 is still an h2. ref, id and other attributes reach the element. With lines, the tooltip of cut text, on hover and on keyboard focus, hidden from screen readers, which read the whole text.

You supply: The outline. Pick each heading's level from where it sits on the page. A wrapper such as a section title should take the level as a prop, or render one level only where that level is always right. Give a heading an id when a region names itself with aria-labelledby.

Watch for: A heading tag on text that does not start a section, such as a bold line inside a card: it adds an entry to the page's list of headings. Use weight="bold" instead. as="strong" marks importance; for the bold look alone, use weight. A tone as the only sign that text means something, such as an error or a selected state. A label is not part of the heading it sits over, so moving through headings skips it: put words the heading needs in the heading. Write a label in sentence case and set its case with text.label.font.text-transform, so a theme can change it. Cutting text a person has to read in full, such as an error or a price, with lines: the tooltip needs a hover or a focus, and on a touch screen plain text gets neither. Keep lines for names and titles whose full text the next screen shows. A link inside clamped text has its focus ring cut at the text's edge, so put the clamped text inside the link instead.

When to use

When: Body text and headings. Tone default / muted / accent, weight, and as p / span / strong / h1–h6. The level picks text.hN.font.size. Eyebrows, kickers and metadata with variant="label". Names and titles cut to a number of lines with lines.

When not: Field names → Label, not variant="label". A group of controls' name → Fieldset.Legend. Hints and errors → Description / ErrorMessage. Dialog heading → Dialog.Title.

Props

Text.Root props
NameTypeDescription
as"p"| "span"| "strong"| "h1"| "h2"| "h3"| "h4"| "h5"| "h6"

Rendered element. A heading level sets the outline, bold weight and tight leading, and draws at text.h1.font.size through text.h6.font.size. Defaults follow font.size.6, font.size.5, font.size.4, text.font.size, text.font.size and font.size.2. With no heading, body draws at text.font.size, whose default is font.size.3.

Default: "p"

variant"label"

The label role for eyebrows, kickers and metadata. It reads text.label.* for its family, size, weight, leading, letter spacing, case and color, and sets font-family, from text.font.family by default. A tone or weight you give wins.

tone"default" | "muted" | "accent"

Foreground role. accent follows color.accent.default, which is neutral ink in Todae, so it matches default until a theme sets a brand accent.

Default: "default"; text.label.fg with variant "label"

weight"regular" | "medium" | "bold"

Font weight.

Default: "regular"; "bold" for headings; text.label.font.weight with variant "label"

linesnumber

Clamps the text to this many lines, a whole number of 1 or more, with an ellipsis at the end of the last line. The element becomes a block. Screen readers still read the whole text.

tooltipboolean

With lines, shows the whole text in a tooltip on hover, or on keyboard focus of the text or a link, row or menu item around it, when the text is cut. The tooltip is hidden from screen readers. The @tounsoo/todae/text entry draws no tooltip.

Default: true

childrenReact.ReactNode

Text content.