# text.code

A block of code or terminal output shown to the reader

Component: [`<Text>`](https://www.prongs.dev/docs/components/text.md) · Renders: `<pre>` · Profile: [UI](https://www.prongs.dev/docs/intents/ui.md)

## Example

```tsx
<Text intent="text.code">Pack my box with five dozen liquor jugs.</Text>
```

## Choosing between neighbours

Find the row that describes your element, and use the intent on the right.

| If it is for… | Use |
|---|---|
| A block of code or terminal output shown to the reader | `text.code` (this page) |
| A sentence that mentions code; wrap the code in <code> inside text.body | [`text.body`](https://www.prongs.dev/docs/intents/text/body.md) |
| Code or a command (rather than [`text.quote`](https://www.prongs.dev/docs/intents/text/quote.md)) | `text.code` (this page) |
| A code sample on the page (rather than [`text.line`](https://www.prongs.dev/docs/intents/text/line.md)) | `text.code` (this page) |
| A code sample on the page (rather than [`text.output`](https://www.prongs.dev/docs/intents/text/output.md)) | `text.code` (this page) |
| A code sample on the page (rather than [`text.diff`](https://www.prongs.dev/docs/intents/text/diff.md)) | `text.code` (this page) |
| A code sample of several lines (rather than [`text.snippet`](https://www.prongs.dev/docs/intents/text/snippet.md)) | `text.code` (this page) |
| An intent named in prose (rather than [`text.marker`](https://www.prongs.dev/docs/intents/text/marker.md)) | `text.code` (this page) |
| A code sample of several lines (rather than [`layout.command`](https://www.prongs.dev/docs/intents/layout/command.md)) | `text.code` (this page) |

## Connections

Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.

- Built from: [`typography.mono`](https://www.prongs.dev/docs/intents/ui.md#typography-mono), [`tone.default`](https://www.prongs.dev/docs/intents/ui.md#tone-default)

## For registry authors

**Starter intents.** These are the intents `prongs add` puts in your registry, shown in this site’s theme. Yours are your own `registry.ts`: rename, restyle and add to them, and see them with `prongs add gallery`.

What this intent is built from and its entry in `components/prongs/registry.ts`. You only need this to change how it looks or to add an intent like it.

How text.code resolves, and its definition

Each layer adds to the one before it; a later class wins over an earlier one that sets the same thing.

- [`typography.mono`](https://www.prongs.dev/docs/intents/ui.md#typography-mono) — Monospaced type

  ```
  font-mono text-sm
  ```

- [`tone.default`](https://www.prongs.dev/docs/intents/ui.md#tone-default) — Main text colour

  ```
  text-foreground
  ```

- `text.code` (this page) — A block of code or terminal output shown to the reader

  ```
  overflow-x-auto whitespace-pre rounded-xl border
  border-code-border bg-surface-0 p-4 leading-[1.7]
  ```

Final classes

```
font-mono text-sm text-foreground overflow-x-auto whitespace-pre
rounded-xl border border-code-border bg-surface-0 p-4
leading-[1.7]
```

Definition

```ts
'text.code': {
  kind: 'semantic',
  description: 'A block of code or terminal output shown to the reader',
  refs: ['typography.mono', 'tone.default'],
  binding: {
    element: 'pre',
    classes: 'overflow-x-auto whitespace-pre rounded-xl border border-code-border bg-surface-0 p-4 leading-[1.7]',
  },
  notFor: [
    {
      context: 'a sentence that mentions code; wrap the code in <code> inside text.body',
      instead: 'text.body',
    },
  ],
},
```
