Type specimen

Set your own sample text, swap typefaces, and size the lettering against a ruler.

Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

bunx --bun shadcn@latest add https://www.cyberspec.dev/r/type-specimen.json

Usage

import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/type-specimen"

export default function App() {
  return (
    <Cyber>
      <Recipe />
    </Cyber>
  )
}

Source

"use client"

import "./recipe-layout.css"
import { useState } from "react"
import { Ruler } from "@/components/ui/micro"
import { SegmentedControl } from "@/components/ui/segmented-control"
import { Slider } from "@/components/ui/slider"
import { TextField } from "@/components/ui/text-field"

export default function TypeSpecimen() {
  const [text, setText] = useState("Night Shift")
  const [face, setFace] = useState("Display")
  const [size, setSize] = useState(44)

  return (
    <div className="sink-stack">
      <div style={{ minHeight: 76, display: "grid", alignContent: "center", minWidth: 0 }}>
        <span style={{ color: "var(--cy-ink-hi)", fontFamily: face === "Display" ? "var(--cy-font)" : "var(--cy-mono)", fontWeight: 600, fontSize: size, lineHeight: 1.1, overflowWrap: "anywhere" }}>{text || "Aa"}</span>
        <Ruler />
      </div>
      <TextField label="Sample text" maxLength={32} value={text} onValueChange={setText} />
      <SegmentedControl label="Typeface" options={["Display", "Mono"]} value={face} onValueChange={(next) => next && setFace(next)} fill />
      <Slider label="Type size" value={size} min={20} max={64} step={2} ticks={11} format={(value) => `${value}px`} onValueChange={setSize} />
    </div>
  )
}

Components in this recipe

  • Text field — A labelled text input in a cut frame, with a hint, an error and an optional icon.
  • Slider — A ticked track with a cut thumb and a value readout, single or range.
  • Segmented control — A row of segments with an indicator that slides to the choice.
  • Micro-print — The printed decoration around frames: micro-print lines, barcodes, rulers, data streams and corner brackets.

Resources

View as Markdown