Skip to main content
A mod draws its interface from elements: text, boxes, buttons, fields, and a few that format content for you. The samples here show the code that draws an element, and most come with a screenshot of the result in a terminal pane, so you can pick an element by how it looks. To learn how drawing works, start with Draw in the interface. For the main props and which apps draw each element, see the elements reference. The type declarations list every prop.

Try a sample

The samples on this page are snippets, not whole mods. Each one is the code for one element and anything nested inside it. To see a sample in your own terminal, create the small mod in these steps and paste the sample into it. The mod adds a /gallery command that opens a pane and draws the sample there. A pane is a sidebar beside the transcript in a wide fullscreen terminal, or a framed region above the prompt otherwise.
1

Create the mod

Create a directory named gallery with .claude-plugin and hooks directories inside it. Create a mod explains the files.Save the manifest as gallery/.claude-plugin/plugin.json:
gallery/.claude-plugin/plugin.json
Name your entry point in gallery/hooks/hooks.json:
gallery/hooks/hooks.json
Save the code as gallery/hooks/register.js. It adds a /gallery command that opens a pane, and draws Plain text in that pane:
gallery/hooks/register.js
2

Run the mod

In your shell, start Claude Code from the directory that holds gallery:
At the Claude Code prompt, run /gallery. A pane opens with Plain text in it.
3

Swap in a sample

Copy a sample from this page. In register.js, paste it over Text({ children: ['Plain text'] }), so that it follows return, and save the file. Claude Code reloads the module each time you save, so run /gallery again to see the new sample.

Pick an element

The samples are grouped by what you want to put on screen:

Show text

Three elements put words on screen: Text for your own styling, Markdown for content that’s already formatted, and Link for a URL.

Text

Text draws a string with the styles you give it. This sample shows one line for each style:
A pane with nine lines of text, each named for its style: plain, bold, italic, underline, strikethrough, dimColor in gray, inverse, color red, and backgroundColor blue. A pane with nine lines of text, each named for its style: plain, bold, italic, underline, strikethrough, dimColor in gray, inverse, color red, and backgroundColor blue. dimColor draws the text in gray. backgroundColor fills only as wide as the text.

Markdown

Markdown formats text the way Claude’s replies are formatted. Pass the content in text, not in children:
A pane with a bold heading, Release notes, then a sentence with one bold word and one colored code word, a two-item list, and a quote drawn in italics with a bar on its left. A pane with a bold heading, Release notes, then a sentence with one bold word and one colored code word, a two-item list, and a quote drawn in italics with a bar on its left. A heading draws in bold without its # marks. Inline code draws in color without its backticks. A quote draws in italics with a bar on its left. Link draws a label followed by its URL:
A pane with one line: the label Claude Code docs, then the URL in gray. A pane with one line: the label Claude Code docs, then the URL in gray. The terminal draws the URL as text after the label. Whether a click opens it depends on the user’s terminal.

Show code and changes

Code draws source text with Claude Code’s own syntax colors, or a diff.

Code

Name the language, or pass a path for Claude Code to infer it from. With startLine, the lines are numbered from that number:
A pane with two numbered lines of JavaScript in syntax colors. A pane with two numbered lines of JavaScript in syntax colors. The colors come from the user’s theme.

Code as a diff

With format: 'diff', source is one or more unified diff hunks:
A pane with a four-line diff. The removed line is shaded red and the added line green, each with its line number. In the added line, the words that runs code have a stronger shade. A pane with a four-line diff. The removed line is shaded red and the added line green, each with its line number. In the added line, the words that runs code have a stronger shade. Claude Code draws line numbers in place of the @@ line. Where a removed line and an added line are alike, the words that changed get a stronger shade.

Arrange elements

Box

Box lays out what’s inside it in a row or a column, and can draw a border. This sample puts a row of words above a bordered box:
A pane with three words in a row, four columns apart, then a blank row, then a rounded border around one line of text. The border runs the full width of the pane. A pane with three words in a row, four columns apart, then a blank row, then a rounded border around one line of text. The border runs the full width of the pane. The border stretches to the width of the pane.

Take input

Button, Input, and Select are controls: the user moves between them with Tab and uses the one that has the focus. Keyboard focus and hotkeys covers which keys reach them. Opening a pane with focus: true gives the pane keyboard focus. Typed letters reach an Input once it has the focus, so add autoFocus: true to a field that should take typing as soon as the pane opens.

Button

A button runs onPress. This sample shows the default form, a plain button with a hotkey, and a dim one:
A pane with three buttons, one per line: Save in brackets, n: Next without brackets and with the n in color, and Skip in brackets in gray. A pane with three buttons, one per line: Save in brackets, n: Next without brackets and with the n in color, and Skip in brackets in gray. A button that has the focus draws in inverse video. Here the user has pressed Tab twice: The same three buttons, with the second one, n: Next, drawn in inverse video. The same three buttons, with the second one, n: Next, drawn in inverse video.

Input

An Input is a one-line text field that runs onSubmit when the user presses Enter:
Without the focus, the field shows its label and its placeholder: A pane with one line: the label Title, then the placeholder Type a title and press Enter in gray. A pane with one line: the label Title, then the placeholder Type a title and press Enter in gray. With the focus, the label turns bold, a cursor appears, and the submitLabel shows after ⏎: The same field with its label in bold, a block cursor on the first letter of the placeholder, and a return sign followed by the word save. The same field with its label in bold, a block cursor on the first letter of the placeholder, and a return sign followed by the word save. Typing replaces the placeholder: The same field holding the typed letters Rel, followed by the return sign and the word save. The same field holding the typed letters Rel, followed by the return sign and the word save.

Select

A Select lets the user pick one of several options, and runs onSelect with the option’s value:
Closed, it shows its label and the current option: A pane with one line: the label Format, the current option Markdown, and a small down arrow. A pane with one line: the label Format, the current option Markdown, and a small down arrow. Open, it lists its options and marks one: The picker open, with its three options listed under the label. The second option, HTML, is drawn in inverse video. The picker open, with its three options listed under the label. The second option, HTML, is drawn in inverse video. After the user picks an option, the list closes: The picker closed again, now showing HTML as the current option. The picker closed again, now showing HTML as the current option.

Draw pictures

Raster

A Raster is a grid of colored character cells, for a heat map, a sparkline, or a game board. The terminal draws it. This sample uses the cellsOf function in the starter module, which packs the cells into the string a Raster takes. Draw a grid of colored cells explains it:
A pane with a small grid of colored blocks, two rows of three: green, amber, and red, then green, green, and amber. A pane with a small grid of colored blocks, two rows of three: green, amber, and red, then green, green, and amber. A Raster rounds each color to a smaller palette, so 0x2e7d32 draws as #337733.

Svg

An Svg draws an SVG document in the Desktop app:
In the terminal, a pane that returns only an Svg opens empty. To draw something else there, check e.surface and return a different tree.

Image and Client

Two more elements have no sample here. Image draws a PNG or raw pixels in the terminal. Client is a region that a second file of yours draws, for animation and pointer input. The elements reference lists their props.

See where a mod can draw

The samples all draw in a pane. A mod can also draw in other places, and call Claude Code to show something for it:

Next steps