Skip to main content

Typography

The kit uses two fonts and 16 text styles. The components pick their text style themselves. Use the same styles in your own text, so your screens match the kit.

The fonts​

FontUsed forWeights the kit uses
Space GroteskEverything: headings, body text, numbers400, 500, 600, 700
Space MonoCode400

Loading the fonts​

The tokens only name the fonts: they don't include the font files. Your app has to load them, or the text falls back to the system font.

The simplest way is the @fontsource packages:

pnpm add @fontsource/space-grotesk @fontsource/space-mono

Then import them once, at the root of your app, next to the kit's styles:

import "@fontsource/space-grotesk/400.css";
import "@fontsource/space-grotesk/500.css";
import "@fontsource/space-grotesk/600.css";
import "@fontsource/space-grotesk/700.css";
import "@fontsource/space-mono/400.css";

import "@detriz-sh-kit/tokens/tokens.css";
import "@detriz-sh-kit/ui/styles.css";

Load each weight you need: a weight you don't load is faked by the browser and looks blurry.

Text styles​

Each style is five tokens: --shk-typography-<style>-font-family, -font-size, -font-weight, -line-height and -letter-spacing.

StyleSizeWeightLine heightUsed by
display64px70070pxBig hero text
h140px70044pxYour page's main heading
h232px60040pxContentSection level 2
h324px60030pxContentSection level 3
h420px60025pxContentSection level 4, ModuleCard and SpaceCard names
body-lg18px40027pxSensorLabel lg
body16px40024pxRunning text, SensorLabel md
body-sm14px40021pxSensorLabel sm
label14px50018pxButton, Switch
caption12px40018pxLocationPath, SensorLabel xs, the Status components
overline12px50018pxSmall labels above a heading
readout-lg48px50053pxReadingValue lg
readout32px50035pxReadingValue md, UnitLabel lg
readout-sm20px50022pxReadingValue sm, UnitLabel md
readout-xs14px50015pxReadingValue xs, UnitLabel sm and xs
code14px40021pxCode (Space Mono)

The readout styles are for numbers: they have tight line heights, so a value and its Unit sit close together.

Loading…
Live editor
function TextStyles() {
  const styles = [
    "display",
    "h1",
    "h2",
    "h3",
    "h4",
    "body-lg",
    "body",
    "body-sm",
    "label",
    "caption",
    "overline",
    "readout-lg",
    "readout",
    "readout-sm",
    "readout-xs",
    "code",
  ];
  const text = (name) => ({
    fontFamily: `var(--shk-typography-${name}-font-family)`,
    fontSize: `var(--shk-typography-${name}-font-size)`,
    fontWeight: `var(--shk-typography-${name}-font-weight)`,
    lineHeight: `var(--shk-typography-${name}-line-height)`,
    letterSpacing: `var(--shk-typography-${name}-letter-spacing)`,
    color: "var(--shk-color-text-primary)",
  });

  return (
    <StackLayout gap="sm">
      {styles.map((name) => (
        <div
          key={name}
          style={{
            display: "flex",
            alignItems: "baseline",
            gap: "var(--shk-space-4)",
          }}
        >
          <code style={{ minInlineSize: "7rem" }}>{name}</code>
          <span style={text(name)}>
            {name.startsWith("readout") ? "22.4" : "Bedroom"}
          </span>
        </div>
      ))}
    </StackLayout>
  );
}

Using a text style in your CSS​

Set all five tokens, so the size, weight and spacing stay in step:

.my-page-title {
font-family: var(--shk-typography-h1-font-family);
font-size: var(--shk-typography-h1-font-size);
font-weight: var(--shk-typography-h1-font-weight);
line-height: var(--shk-typography-h1-line-height);
letter-spacing: var(--shk-typography-h1-letter-spacing);
}

Match the text style to the HTML element: h2 for an <h2>, and so on. That way what people see matches what screen readers announce. ContentSection does this for you.

Numbers​

Values in the Readings components use tabular figures: every digit is the same width, so a layout doesn't jump when 19.9 becomes 20.0. Use the same in your own lists of numbers:

.my-table td {
font-variant-numeric: tabular-nums;
}