Interface gallery for mods - Claude Code Docs
Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. 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" : "gallery" , "version" : "0.1.0" , "description" : "Opens a pane that draws one sample" , "author" : { "name" : "Your Name" } } Name your entry point in gallery/hooks/hooks.json : gallery/hooks/hooks.json { "modules" : [ "./register.js" ] } 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 // Stands in for your own callback in the samples that take one const noop = () => {} // The Select sample keeps its choice here let picked = 'md' // The Raster sample packs its cells with this function const DEFAULT_COLOR = 0x01000000 function cellsOf ( rows ) { const numbers = rows . flat (). flatMap (([ char , color ]) => [ char . codePointAt ( 0 ), color , DEFAULT_COLOR ]) return new Uint8Array ( Uint32Array . from ( numbers ). buffer ). toBase64 () } export function register ( on ) { on ( 'session.start' , async ( $ , e , next ) => { await $ . command . register ({ name: 'gallery' , description: 'Open the sample pane' }) return next ( e ) }) on ( 'command.run' , { command: 'gallery' }, async ( $ ) => { await $ . ui . open ({ id: 'gallery' , focus: true , closeOnEscape: true }) return {} }) on ( 'ui.render' , { component: 'Pane' }, async ( $ , e , next ) => { if ( e . requestId !== 'gallery' ) return next ( e ) const { Box , Text , Button , Input , Select , Link , Markdown , Code , Raster , Svg } = $ . ui . resolve ( e ) // Replace the element after return with a sample return Text ({ children: [ 'Plain text' ] }) }) } 2 Run the mod In your shell, start Claude Code from the directory that holds gallery : claude --plugin-dir ./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 : Text , Markdown , and Link Show code and changes : Code Arrange elements : Box Take input : Button , Input , and Select Draw pictures : Raster , Svg , Image , and Client 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 plain text and eight styles, one on each line: Box ({ flexDirection: 'column' , children: [ Text ({ children: [ 'Plain text' ] }), Text ({ bold: true , children: [ 'bold' ] }), Text ({ italic: true , children: [ 'italic' ] }), Text ({ underline: true , children: [ 'underline' ] }), Text ({ strikethrough: true , children: [ 'strikethrough' ] }), Text ({ dimColor: true , children: [ 'dimColor' ] }), Text ({ inverse: true , children: [ 'inverse' ] }), Text ({ color: 'red' , children: [ "color: 'red'" ] }), Text ({ backgroundColor: 'blue' , children: [ "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 : Markdown ({ text: '## Release notes \n\n This build has **two** fixes and one `flag`: \n\n - Faster start \n - Fewer prompts \n\n > Quoted text' , }) 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 Link draws a label followed by its URL: Link ({ href: 'https://code.claude.com/docs' , label: 'Claude Code docs' }) 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. In the VS Code extension, Code shows its source as plain text, with none of the colors, line numbers, or diff shading in these screenshots. Code Name the language , or pass a path for Claude Code to infer it from. With startLine , the lines are numbered from that number: Code ({ language: 'javascript' , startLine: 1 , source: "const name = 'mods' \n console.log('hello ' + name)" , }) The colors come from the user’s theme.
Code as a diff With format: 'diff' , source is one or more unified diff hunks: Code ({ format: 'diff' , source: '@@ -1,3 +1,3 @@ \n # Mods \n -A mod is a plugin. \n +A mod is a plugin that runs code. \n Read on.' , }) 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: Box ({ flexDirection: 'column' , gap: 1 , children: [ Box ({ flexDirection: 'row' , columnGap: 4 , children: [ Text ({ children: [ 'a row' ] }), Text ({ children: [ 'of three' ] }), Text ({ children: [ 'items' ] })], }), Box ({ borderStyle: 'round' , paddingX: 1 , children: [ Text ({ children: [ "borderStyle: 'round'" ] })], }), ], }) 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. Open a pane with focus: true to request keyboard focus for it. Typed letters reach an Input once it has the focus. To choose which field has the focus when the pane opens, see Set a hotkey and the first focus . Button A button runs onPress .
This sample shows the default form, a plain button with a hotkey, and a dim one: Box ({ flexDirection: 'column' , children: [ Button ({ key: 'save' , label: 'Save' , onPress: noop }), Button ({ key: 'next' , label: 'Next' , hotkey: 'n' , plain: true , onPress: noop }), Button ({ key: 'skip' , label: 'Skip' , dimColor: true , onPress: noop }), ], }) A button that has the focus draws in inverse video. Here the user has pressed Tab twice: Input An Input is a text field that holds one line by default and runs onSubmit when the user presses Enter: Input ({ key: 'title' , label: 'Title' , placeholder: 'Type a title and press Enter' , value: '' , submitLabel: 'save' , onSubmit: noop , }) Without the focus, the field shows its label and its placeholder: With the focus, the label turns bold, a cursor appears, and the submitLabel shows after ⏎ : Typing replaces the placeholder: Set rows to 2 or more for a field that holds several lines, such as a note or a commit message: Input ({ key:
The rest of this page is on the live site.