# Type specimen

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

[View Type specimen on CyberSpec](https://www.cyberspec.dev/sink/type-specimen)

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

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

## Usage

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

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

## Source

```tsx
"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](https://www.cyberspec.dev/components/sidebar/text-field.md) — A labelled text input in a cut frame, with a hint, an error and an optional icon.
- [Slider](https://www.cyberspec.dev/components/sidebar/slider.md) — A ticked track with a cut thumb and a value readout, single or range.
- [Segmented control](https://www.cyberspec.dev/components/sidebar/segmented-control.md) — A row of segments with an indicator that slides to the choice.
- [Micro-print](https://www.cyberspec.dev/components/sidebar/micro.md) — The printed decoration around frames: micro-print lines, barcodes, rulers, data streams and corner brackets.

## Resources

- [All kitchen sink recipes](https://www.cyberspec.dev/sink.md)
- [Recipe source on GitHub](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/type-specimen.tsx)
- [Recipe layout stylesheet](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/recipe-layout.css)
- [Shadcn registry item](https://www.cyberspec.dev/r/type-specimen.json)
