# Typeset

Typography for markdown you don't control.

Source: https://webjs.dev/ui/typeset

- Google FontsSelf-hosted

### 1. Create typeset.css

Copy the stylesheet into `public/typeset.css`, then import it in `public/input.css`:

[Copy typeset.css](https://webjs.dev/ui/typeset.css)

```
@import "tailwindcss";
@import "./typeset.css";
```

### 2. Add the fonts

Link the fonts in your root layout:

```
<!-- app/layout.ts, in <head> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap">
```

Then name them in your CSS file:

```
/* public/input.css */
:root {
  --font-geist: 'Geist', sans-serif;
  --font-geist-mono: 'Geist Mono', monospace;
}
```

### 3. Create your custom typeset

```
/* public/input.css */
@import "tailwindcss";
@import "./typeset.css";

.typeset-docs {
  --typeset-font-body: var(--font-geist);
  --typeset-font-heading: var(--font-geist);
  --typeset-font-mono: var(--font-geist-mono);
  --typeset-size: 15px;
  --typeset-leading: 1.75;
  --typeset-flow: 1.25em;
}
```

### 4. Wrap your content

```
<div class="typeset typeset-docs max-w-[37em]">
  ${content}
</div>
```

One prompt with your picks baked in. Copy it and paste it into your coding agent.

```
Install shadcn/typeset in this WebJs app.

Typeset is a single stylesheet that styles rendered markdown: wrap the output in a `typeset` container and everything inside (headings, lists, tables, code, blockquotes, math) is styled. Everything outside is untouched.

1. Download https://webjs.dev/ui/typeset.css and save it as public/typeset.css, next to public/input.css (the Tailwind input the app compiles to public/tailwind.css). If the file already exists, replace it with the downloaded copy.

2. Import it in public/input.css, after the Tailwind import:

@import "./typeset.css";

3. Load the fonts with a stylesheet link in the root layout, app/layout.ts, inside <head>:

<!-- app/layout.ts, in <head> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap">

Then name them in public/input.css:

:root {
  --font-geist: 'Geist', sans-serif;
  --font-geist-mono: 'Geist Mono', monospace;
}

4. Add this preset to public/input.css, after the typeset import. If a class named .typeset-docs already exists, update its values in place. Leave any other typeset-* presets untouched: they are separate surfaces:

.typeset-docs {
  --typeset-font-body: var(--font-geist);
  --typeset-font-heading: var(--font-geist);
  --typeset-font-mono: var(--font-geist-mono);
  --typeset-size: 15px;
  --typeset-leading: 1.75;
  --typeset-flow: 1.25em;
}

5. Do not apply the class anywhere yet. Search the project for surfaces that render markdown or rich content: unsafeHTML holes fed parsed markdown, markdown renderers (marked, markdown-it, remark), prose classes, CMS content renderers. Present the candidates you find as a short list and ask the user which surface should use typeset. Then wrap only the surface they pick, in its html template:

<div class="typeset typeset-docs max-w-[37em]">
  ${content}
</div>

If the picked surface already has its own typography (a prose class, styled markdown elements), list those styles and let the user decide what to remove before wrapping.

Notes:

- To exclude an embedded component from typeset styles, add the not-typeset class or the data-not-typeset attribute to it.
- Verify on the surface the user picked: headings, lists, tables, and code inside the container should be styled with no classes on the content itself.
- Docs: https://ui.shadcn.com/docs/typeset
```

[Read the docs](https://ui.shadcn.com/docs/typeset)

[typeset preview](https://webjs.dev/ui/preview/typeset/docs)

[Open in New Tab](https://webjs.dev/ui/preview/typeset/docs)

[Shuffle R](https://webjs.dev/ui/typeset?body=figtree&heading=roboto&mono=jetbrains-mono&scale=18&measure=90&flow=1em)

[Reset ⇧R](https://webjs.dev/ui/typeset)

- 60ch 70ch 80ch 90ch
- Apply

- Geist Geist Inter Noto Sans Nunito Sans Figtree Roboto Raleway DM Sans Public Sans Outfit Oxanium Manrope Space Grotesk Montserrat IBM Plex Sans Source Sans 3 Instrument Sans Noto Serif Roboto Slab Merriweather Lora JetBrains Mono Geist Mono
- Apply

- Geist Inter Noto Sans Nunito Sans Figtree Roboto Raleway DM Sans Public Sans Outfit Oxanium Manrope Space Grotesk Montserrat IBM Plex Sans Source Sans 3 Instrument Sans Noto Serif Roboto Slab Merriweather Lora JetBrains Mono Geist Mono
- Apply

- Geist Inter Noto Sans Nunito Sans Figtree Roboto Raleway DM Sans Public Sans Outfit Oxanium Manrope Space Grotesk Montserrat IBM Plex Sans Source Sans 3 Instrument Sans Noto Serif Roboto Slab Merriweather Lora JetBrains Mono Geist Mono
- Apply

- 14px 15px 16px 18px
- Apply

- Tight (1.6) Regular (1.75) Loose (1.9)
- Apply

- Compact (1em) Regular (1.25em) Airy (2em)
- Apply

[Shuffle](https://webjs.dev/ui/typeset?body=raleway&mono=jetbrains-mono&scale=16&measure=90&flow=1em)

## Get Code

Install typeset with the values you picked.

- Google FontsSelf-hosted

### 1. Create typeset.css

Copy the stylesheet into `public/typeset.css`, then import it in `public/input.css`:

[Copy typeset.css](https://webjs.dev/ui/typeset.css)

```
@import "tailwindcss";
@import "./typeset.css";
```

### 2. Add the fonts

Link the fonts in your root layout:

```
<!-- app/layout.ts, in <head> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap">
```

Then name them in your CSS file:

```
/* public/input.css */
:root {
  --font-geist: 'Geist', sans-serif;
  --font-geist-mono: 'Geist Mono', monospace;
}
```

### 3. Create your custom typeset

```
/* public/input.css */
@import "tailwindcss";
@import "./typeset.css";

.typeset-docs {
  --typeset-font-body: var(--font-geist);
  --typeset-font-heading: var(--font-geist);
  --typeset-font-mono: var(--font-geist-mono);
  --typeset-size: 15px;
  --typeset-leading: 1.75;
  --typeset-flow: 1.25em;
}
```

### 4. Wrap your content

```
<div class="typeset typeset-docs max-w-[37em]">
  ${content}
</div>
```

One prompt with your picks baked in. Copy it and paste it into your coding agent.

```
Install shadcn/typeset in this WebJs app.

Typeset is a single stylesheet that styles rendered markdown: wrap the output in a `typeset` container and everything inside (headings, lists, tables, code, blockquotes, math) is styled. Everything outside is untouched.

1. Download https://webjs.dev/ui/typeset.css and save it as public/typeset.css, next to public/input.css (the Tailwind input the app compiles to public/tailwind.css). If the file already exists, replace it with the downloaded copy.

2. Import it in public/input.css, after the Tailwind import:

@import "./typeset.css";

3. Load the fonts with a stylesheet link in the root layout, app/layout.ts, inside <head>:

<!-- app/layout.ts, in <head> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap">

Then name them in public/input.css:

:root {
  --font-geist: 'Geist', sans-serif;
  --font-geist-mono: 'Geist Mono', monospace;
}

4. Add this preset to public/input.css, after the typeset import. If a class named .typeset-docs already exists, update its values in place. Leave any other typeset-* presets untouched: they are separate surfaces:

.typeset-docs {
  --typeset-font-body: var(--font-geist);
  --typeset-font-heading: var(--font-geist);
  --typeset-font-mono: var(--font-geist-mono);
  --typeset-size: 15px;
  --typeset-leading: 1.75;
  --typeset-flow: 1.25em;
}

5. Do not apply the class anywhere yet. Search the project for surfaces that render markdown or rich content: unsafeHTML holes fed parsed markdown, markdown renderers (marked, markdown-it, remark), prose classes, CMS content renderers. Present the candidates you find as a short list and ask the user which surface should use typeset. Then wrap only the surface they pick, in its html template:

<div class="typeset typeset-docs max-w-[37em]">
  ${content}
</div>

If the picked surface already has its own typography (a prose class, styled markdown elements), list those styles and let the user decide what to remove before wrapping.

Notes:

- To exclude an embedded component from typeset styles, add the not-typeset class or the data-not-typeset attribute to it.
- Verify on the surface the user picked: headings, lists, tables, and code inside the container should be styled with no classes on the content itself.
- Docs: https://ui.shadcn.com/docs/typeset
```
