# Typography

import { Callout } from "fumadocs-ui/components/callout";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
import { Badge, Card, CardContent, CardHeader, CardTitle } from "@pycolors/ui";
import { CheckCircle, FormInput, ListTree, MousePointerClick, Palette, Ruler, ShieldCheck, Type, XCircle } from "lucide-react";
import { PreferAvoid } from '@/components/docs/prefer-avoid';
import { DocsLinks } from "@/components/docs/docs-links";
import { DocsFeatureGrid } from "@/components/docs/docs-feature-grid";

<div className="flex flex-wrap items-center gap-2">
  <Badge variant="outline">
    Design System
  </Badge>

  <Badge>
    Typography
  </Badge>
</div>

## Overview

Typography is one of the strongest signals of product quality. It gives every interface a readable structure before color, spacing, motion, or decoration are added.

PyColors treats typography as a **system**, not as local page styling. The goal is to keep dashboards, documentation, settings pages, marketing sections, forms, and product flows readable and consistent as the product grows.

At the end of this page, you will understand how PyColors handles:

* font roles
* heading hierarchy
* body text density
* labels and metadata
* semantic text roles
* production usage rules

<Callout title="Why this matters">
  A weak type system makes a product feel unfinished even when the UI components are correct. Stable typography improves scanning, reduces visual noise, and makes the interface feel more deliberate.
</Callout>

## What you’ll define

<DocsFeatureGrid
  columns={3}
  tone="platform"
  items={[
  {
    title: 'Font roles',
    description:
      'Separate UI text, brand accents, and technical values with predictable font variables.',
    icon: Type,
  },
  {
    title: 'Hierarchy',
    description:
      'Use a limited heading ladder so pages stay scannable without overloading the table of contents.',
    icon: ListTree,
  },
  {
    title: 'Usage rules',
    description:
      'Keep text roles semantic so reusable components stay coherent across light and dark mode.',
    icon: ShieldCheck,
  },
]}
/>

## Steps

<Steps>
  <Step>
    ### Use font roles instead of font choices

    PyColors exposes fonts as CSS variables and utilities. Components should depend on the role of the font, not on a hardcoded family.

    ```tsx title="app/layout.tsx" {1}
    import { Inter } from "next/font/google";

    const inter = Inter({
      subsets: ["latin"],
      variable: "--font-sans", // highlight
    });
    ```

    Common roles are:

    | Role             | Utility      | Purpose                                   |
    | ---------------- | ------------ | ----------------------------------------- |
    | UI and content   | `font-sans`  | Default interface and readable content    |
    | Brand accent     | `font-brand` | Headings, hero sections, premium identity |
    | Technical values | `font-mono`  | Code, IDs, tokens, CLI output             |

    <Callout type="info" title="Implementation note">
      The exact font family can change over time. The important part is that components keep consuming stable font roles.
    </Callout>
  </Step>

  <Step>
    ### Choose density by surface

    PyColors keeps text density simple. Product interfaces should stay efficient, while documentation and marketing content should feel easier to read.

    | Surface                     | Default     | Reason                                          |
    | --------------------------- | ----------- | ----------------------------------------------- |
    | SaaS UI and dashboards      | `text-sm`   | Dense enough for product workflows              |
    | Docs, guides, and marketing | `text-base` | More comfortable for reading                    |
    | Labels and metadata         | `text-xs`   | Compact context without competing with headings |

    This split keeps dashboards efficient while making documentation feel calm and premium.
  </Step>

  <Step>
    ### Build hierarchy with a limited scale

    Headings should make structure obvious without turning every section into a visual event.

    <Tabs items={['Preview', 'Code']}>
      <Tab value="Preview">
        <div className="not-prose rounded-[5px] border border-border-subtle bg-card p-6 shadow-soft">
          <div className="space-y-4">
            <div className="text-4xl font-semibold tracking-tight text-foreground">
              Page title
            </div>

            <div className="text-3xl font-semibold tracking-tight text-foreground">
              Section title
            </div>

            <div className="text-2xl font-semibold tracking-tight text-foreground">
              Subsection title
            </div>

            <div className="text-xl font-medium tracking-tight text-foreground">
              Minor heading
            </div>

            <div className="text-base leading-7 text-muted-foreground">
              Readable body text with enough rhythm for documentation and product copy.
            </div>
          </div>
        </div>
      </Tab>

      <Tab value="Code">
        ```tsx filename="components/heading-hierarchy.tsx"
        export function HeadingHierarchy() {
          return (
            <div className="space-y-4">
              <h1 className="text-4xl font-semibold tracking-tight">
                Page title
              </h1>
              <h2 className="text-3xl font-semibold tracking-tight">
                Section title
              </h2>
              <h3 className="text-2xl font-semibold tracking-tight">
                Subsection title
              </h3>
              <h4 className="text-xl font-medium tracking-tight">
                Minor heading
              </h4>
              <p className="text-base leading-7 text-muted-foreground">
                Readable body text.
              </p>
            </div>
          );
        }
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Why it matters

Typography is where product quality becomes visible. Users may not notice the type system directly, but they notice when the product feels harder to scan, less structured, or visually inconsistent.

Without a stable typography system, you will:

* invent heading sizes page by page
* overuse font weight to create emphasis
* make dashboards visually noisy
* reduce trust in product and documentation surfaces
* make components harder to reuse consistently

With a stable system, every page feels calmer, more intentional, and easier to understand.

<Callout title="Product principle">
  Typography should reduce cognitive load. It should guide the reader through the product, not compete for attention.
</Callout>

### Text roles

<Tabs items={["Body", "Labels", "States"]}>
  <Tab value="Body">
    <div className="max-w-prose space-y-3 rounded-2xl border border-border/60 bg-card p-6">
      <div className="text-base leading-7 text-foreground">
        Primary text is used for the main content a user needs to read or act on.
      </div>

      <div className="text-sm leading-6 text-muted-foreground">
        Secondary text supports the main message with descriptions, helper copy, and contextual details.
      </div>

      <div className="text-xs leading-5 text-muted-foreground">
        Metadata is reserved for timestamps, labels, status hints, and compact secondary information.
      </div>
    </div>
  </Tab>

  <Tab value="Labels">
    <div className="rounded-2xl border border-border/60 bg-card p-6">
      <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
        Product status
      </div>

      <div className="mt-2 text-base font-medium text-foreground">
        Ready for production review
      </div>

      <div className="mt-1 text-sm leading-6 text-muted-foreground">
        Labels help orientation without becoming headings.
      </div>
    </div>
  </Tab>

  <Tab value="States">
    <div className="grid gap-3 sm:grid-cols-3">
      <div className="rounded-2xl border border-border/60 bg-card p-4">
        <div className="text-sm font-medium text-foreground">
          Default
        </div>

        <div className="mt-1 text-sm text-muted-foreground">
          Neutral product information.
        </div>
      </div>

      <div className="rounded-2xl border border-border/60 bg-card p-4">
        <div className="text-sm font-medium text-destructive">
          Destructive
        </div>

        <div className="mt-1 text-sm text-muted-foreground">
          Errors and dangerous actions.
        </div>
      </div>

      <div className="rounded-2xl border border-border/60 bg-card p-4">
        <div className="text-sm font-medium text-primary">
          Action
        </div>

        <div className="mt-1 text-sm text-muted-foreground">
          Links and primary intent.
        </div>
      </div>
    </div>
  </Tab>
</Tabs>

| Role                 | Utility                 | Usage                                       |
| -------------------- | ----------------------- | ------------------------------------------- |
| Primary text         | `text-foreground`       | Main readable content                       |
| Secondary text       | `text-muted-foreground` | Descriptions, helper text, supporting copy  |
| Brand or action text | `text-primary`          | Links and highlighted actions               |
| Destructive text     | `text-destructive`      | Errors, deletion flows, dangerous messaging |
| Technical text       | `font-mono`             | Code, tokens, identifiers, CLI values       |

### Usage rules

Use typography roles to create consistent product surfaces instead of styling text from scratch each time.

```tsx filename="components/product-summary.tsx"
export function ProductSummary() {
  return (
    <section className="space-y-2">
      <p className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
        Starter Pro
      </p>
      <h2 className="text-2xl font-semibold tracking-tight">
        Production-shaped SaaS foundation
      </h2>
      <p className="max-w-prose text-sm leading-6 text-muted-foreground">
        Use semantic text roles to keep product copy, labels, and descriptions
        predictable across reusable surfaces.
      </p>
    </section>
  );
}
```

## Decision guide

Use this typography system if:

* you are building SaaS dashboards, docs, settings, or marketing pages
* you need consistent hierarchy across multiple product areas
* you want reusable components to feel coherent without local overrides
* you care about light and dark mode readability

Do not override it if:

* the change only solves one local visual preference
* the same need appears in multiple places and should become a token
* the new size, weight, or color weakens hierarchy consistency

<Callout title="Ready to move from design system to product foundation?">
  Starter Pro gives you a stronger SaaS baseline with auth, billing, backend structure, and production-shaped flows. → `/docs/starter-pro`
</Callout>

## Common mistakes

<PreferAvoid
  prefer={[
  'limited heading sizes',
  'semantic text colors',
  'muted helper copy',
  'labels for metadata',
  'reasonable line lengths',
]}
  avoid={[
  'too many font sizes in one panel',
  'uppercase long-form copy',
  'raw color values for text',
  'random heading sizes between pages',
  'using weight instead of structure',
]}
/>

<Accordions type="single">
  <Accordion title="Why not use a larger scale everywhere?">
    Large scales make landing pages feel expressive, but they can make SaaS products harder to scan. PyColors keeps the default scale restrained so dashboards, docs, and product flows stay predictable.
  </Accordion>

  <Accordion title="Should labels be headings?">
    No. Labels provide context. Headings define structure. Keeping them separate makes content easier to scan and prevents the table of contents from becoming too long.
  </Accordion>

  <Accordion title="Can I customize the font family?">
    Yes. Keep the same role-based variables and replace the underlying family. Components should continue using `font-sans`, `font-brand`, and `font-mono`.
  </Accordion>
</Accordions>

## Next steps

<DocsLinks
  variant="grid"
  tone="platform"
  items={[
  {
    title: 'Colors',
    href: '/docs/design-system/colors',
    description:
      'Pair typography with semantic color roles for text, surfaces, and states.',
    icon: Palette,
  },
  {
    title: 'Radius',
    href: '/docs/design-system/tokens/radius',
    description:
      'Understand how corner geometry supports readable product surfaces.',
    icon: Ruler,
  },
  {
    title: 'Button',
    href: '/docs/ui/button',
    description:
      'See how typography behaves inside interactive elements.',
    icon: MousePointerClick,
  },
  {
    title: 'Input',
    href: '/docs/ui/input',
    description:
      'Review labels, helper text, validation copy, and form readability.',
    icon: FormInput,
  },
]}
/>