201 201
202### Change what Claude Code already draws202### Change what Claude Code already draws
203 203
204Claude Code draws most of its interface itself: messages, tool call rows, the spinner, and more. Each of those parts is a render site too, so a mod can restyle or replace it. To change one, filter your `ui.render` hook on its name from this table:204To change a part Claude Code draws, filter your `ui.render` hook on a render site from this table:
205 205
206| Site | What it is |206| Site | What it is |
207| :- | :- |207| :- | :- |
208| `UserMessage`, `AssistantMessage` | A message in the transcript |208| `UserMessage`, `AssistantMessage` | A message in the transcript |
209| `ToolUse`, `ToolResult`, `ToolGroup` | A tool call's row, its result, and a collapsed group of calls |209| `ToolUse`, `ToolResult`, `ToolGroup` | A tool call's row, its result, and a collapsed group of calls |
210| `CommandOutput` | The row a command printed |210| `CommandOutput` | The row a command printed |
211| `AskUserQuestion` | The dialog Claude opens to ask you a question |211| `AskUserQuestion` | The dialog Claude opens to ask you a question. A `ui.render` hook can't replace it. |
212| `Spinner`, `ToolProgress`, `TurnDuration` | Status lines for a turn: the line that animates while Claude works, a running tool's live progress line, and the line that closes a turn |212| `Spinner`, `ToolProgress`, `TurnDuration` | Status lines for a turn: the line that animates while Claude works, a running tool's live progress line, and the line that closes a turn |
213| `InfoNotice`, `SessionMode`, `PromptHint` | Status lines under the logo, the mode labels in the footer, and the hint line under the prompt |213| `InfoNotice`, `SessionMode`, `PromptHint` | Status lines under the logo, the mode labels in the footer, and the hint line under the prompt |
214| `AgentRow` | A subagent's or teammate's row in the agent panel |214| `AgentRow` | A subagent's or teammate's row in the agent panel |
215 215
216`Pane`, `AskUserQuestion`, `Spinner`, `UserMessage`, `AssistantMessage`, and the tool call sites work in the terminal, the Desktop app, and the VS Code extension. The [render sites table](https://code.claude.com/docs/en/plugins/mods/reference.md#render-sites) lists where each of the others is raised.216`Pane`, `AbovePrompt`, `AskUserQuestion`, `Spinner`, `UserMessage`, `AssistantMessage`, and the tool call sites work in the terminal, the Desktop app, and the VS Code extension. The [render sites table](https://code.claude.com/docs/en/plugins/mods/reference.md#render-sites) lists where each of the others is raised. To change the bubbles and font of messages in the Desktop app without a `ui.render` hook, [style the messages with a theme](#style-messages-in-the-desktop-app).
217 217
218At a site Claude Code already draws, your hook can change a detail, replace the drawing, or leave it alone. Select a tab to see each one applied to the spinner. The examples read a `calls` variable that another hook counts, as in the [tutorial mod](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself).218Select a tab to see a hook change a spinner detail, replace the spinner, or leave it alone. The examples read a `calls` variable that another hook counts, as in the [tutorial mod](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself).
219 219
220> [tab] Change a detail220> [tab] Change a detail
221>221>
439 439
440* **The `backdrop` fields**: `scene` is a [name](https://code.claude.com/docs/en/plugins/mods/reference.md#limits) you choose for a backdrop your hook draws. For the other fields and `overrideColorScheme`, see [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build).440* **The `backdrop` fields**: `scene` is a [name](https://code.claude.com/docs/en/plugins/mods/reference.md#limits) you choose for a backdrop your hook draws. For the other fields and `overrideColorScheme`, see [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build).
441* **Whether the backdrop is drawn**: `$.theme.set` resolves with `isDrawn: true` when a Desktop or mobile app connected to the session says it draws backdrops. Otherwise `isDrawn` is `false` and `reason` says why.441* **Whether the backdrop is drawn**: `$.theme.set` resolves with `isDrawn: true` when a Desktop or mobile app connected to the session says it draws backdrops. Otherwise `isDrawn` is `false` and `reason` says why.
442* **One theme for each session**: a mod that calls `$.theme.set` replaces the session's backdrop and [colors](#change-the-colors-of-the-desktop-app), and a mod that calls `$.theme.clear()` removes them, whichever mod set them. Call `$.theme.clear()` only when the user asks for it.442* **One theme for each session**: a mod that calls `$.theme.set` replaces the session's backdrop, [colors](#change-the-colors-of-the-desktop-app), [message style](#style-messages-in-the-desktop-app), and [sound](#add-sound-to-a-theme), and a mod that calls `$.theme.clear()` removes them, whichever mod set them. Call `$.theme.clear()` only when the user asks for it.
443
444### Animate a backdrop with a shader
445
446To make a [backdrop](#put-a-backdrop-behind-the-conversation) that moves and follows the user's pointer in the Desktop app's Code tab, wrap an `Svg` in a [`Shader`](https://code.claude.com/docs/en/plugins/mods/reference#elements) element. The element names a shader file, which is code that computes each pixel's color on the GPU. The app draws the result over the `Svg`. `Shader` requires Claude Code v2.1.326 or later in the Code tab, so [check the version there](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab) first.
447
448These steps create a mod named `glow`. It draws a light under the pointer, and a click on the backdrop changes the color of the light.
449
450**1. Save the manifest and hooks.json**
451
452From [Write a mod yourself](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself), save `.claude-plugin/plugin.json` and `hooks/hooks.json` in `~/.claude/skills/glow/`, and change `first-mod` to `glow` in both files. A mod [under `~/.claude/skills/`](https://code.claude.com/docs/en/plugins/create#scaffold-a-plugin-that-loads-every-session) loads when you start a session.
453
454**2. Write the shader**
455
456Save this file as `~/.claude/skills/glow/hooks/glow.ts`. Claude Code provides the `claude-code/shader` module it imports.
457
458The shader draws a light around the pointer, blue when `warm` is `0` and orange when it's `1`:
459
460```typescript glow/hooks/glow.ts theme={null}
461import {
462 length, max, min, mix, picture, pointers, shader, smoothstep, values, vec2, vec3, vec4,
463} from 'claude-code/shader'
464
465// Declare each number the mod sets through the Shader's values, with its range
466const { warm } = values({ warm: [0, 1] })
467
468// This function runs once for every pixel and returns that pixel's color
469const glow = picture(pixel => {
470 let light = 0
471 // The loop sees the mouse, each finger, and for one second each pointer that lifted
472 // A mouse that rests for half a second counts as lifted
473 for (const pointer of pointers) {
474 // Subtracting two positions subtracts their x and their y, in points
475 // The result is typed as a plain number, so vec2() marks it as a position again
476 const near = smoothstep(200, 0, length(vec2(pixel.point - pointer.at)))
477 // A pointer fades in over a quarter second, then out as gone counts from 0 to 1
478 const fade = min(pointer.age * 4, 1) * (1 - pointer.gone)
479 light = max(light, near * near * fade)
480 }
481 const color = mix(vec3(0.25, 0.55, 1), vec3(1, 0.45, 0), warm)
482 const alpha = 0.7 * light
483 // The color is premultiplied: red, green and blue are multiplied by alpha
484 return vec4(color * alpha, alpha)
485})
486
487// A shader runs its passes in order, and this one has a single pass
488export default shader({ passes: [glow] })
489```
490
491**3. Draw the backdrop**
492
493Save this file as `~/.claude/skills/glow/hooks/register.js`. The mod sets the theme when a session starts, and draws a `Shader` with one `Svg` child.
494
495The mod's [`ui.pointer`](https://code.claude.com/docs/en/plugins/mods/reference#interface) hook runs after a click, flips `warm`, and asks for a redraw:
496
497```javascript glow/hooks/register.js theme={null}
498const STILL =
499 '<svg xmlns="http://www.w3.org/2000/svg"' +
500 ' viewBox="0 0 1 1" preserveAspectRatio="none">' +
501 '<rect width="1" height="1" fill="#1a3a9c"/>' +
502 '</svg>'
503
504let warm = 0
505
506export function register(on) {
507 on('session.start', async ($, e, next) => {
508 // The scene is a name you choose for the backdrop your hook draws
509 await $.theme.set({ backdrop: { scene: 'glow' }, overrideColorScheme: 'dark' })
510 return next(e)
511 })
512
513 on('ui.render', { component: 'Backdrop' }, async ($, e, next) => {
514 // This hook runs for every mod's backdrop, so pass on the others
515 if (e.props.plugin !== $.plugin.name || e.props.scene !== 'glow') return next(e)
516 const { Shader, Svg } = $.ui.resolve(e)
517 // module must be a string literal, relative to this file
518 return Shader({
519 module: './glow.ts',
520 values: { warm },
521 children: [Svg({ source: STILL, alt: 'A dark blue background' })],
522 })
523 })
524
525 on('ui.pointer', async ($, e, next) => {
526 warm = 1 - warm
527 $.ui.invalidate('ui.render')
528 return next(e)
529 })
530}
531```
532
533**4. Check the shader**
534
535This step is optional and needs [the CLI](https://code.claude.com/docs/en/quickstart.md), which has its own version number. Go to `~/.claude/skills/` in your shell, run `claude plugin validate ./glow`, and look for `shader hooks/glow.ts: runs on any GPU` in the output. If the output names a line in `glow.ts` as an error, fix that line.
536
537A CLI older than v2.1.326 reports `"ui.pointer" is not an event`. If yours does, [update it](https://code.claude.com/docs/en/setup.md#update-claude-code) and run the command again.
538
539**5. Try the backdrop**
540
541Start a new local session in the Code tab by sending a message. The background turns dark blue. If it doesn't, turn off any other mod that sets a theme and start a new session, because a session has [one theme](#put-a-backdrop-behind-the-conversation). If the background still doesn't change, [find out why the mod does nothing](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing).
542
543Move the pointer. A blue light follows it, and fades when you stop. If no light appears, see [Fix a backdrop that shows only the `Svg`](#fix-a-backdrop-that-shows-only-the-svg). Click the empty space beside the conversation, then move the pointer again. The light is now orange. If it's still blue, answer any permission prompt or question from Claude, then click again quickly without dragging, away from messages and buttons.
544
545To try a change, save `glow.ts` or `register.js`, and the mod reloads in the running session. If the change doesn't show within a few seconds, send a message to load it. To turn the mod off, move `glow` out of `~/.claude/skills/` and start a new session.
546
547Follow these rules for pointer input, the shader, and the `Svg` when you build on the example:
548
549* **Clicks**: your mod gets `ui.pointer` when it has set the theme and the user clicks a part of the backdrop that the app doesn't cover. The app sends two clicks a second at most and drops the rest. To draw a press effect without changing your mod's state, use `pointer.down * (1 - pointer.gone)` in the shader, which is `1` during a press and then fades.
550* **Click position**: `e.x` and `e.y` run from `0` to `1`, starting at the backdrop's top left. In the shader, `pixel.uv` has the same scale and starts at the bottom left. To draw at the click, send `e.x` and `1 - e.y` through `values`.
551* **Movement**: read pointer movement from `pointers` in the shader, because moving the pointer doesn't fire `ui.pointer`. For motion over time, import `time`, the seconds since the shader started.
552* **Presses**: to time an effect from a press, check every pointer in the loop for `down` at `1` and read its `age`, the seconds since the press. A press arrives as a new pointer, so it isn't always first in `pointers`.
553* **`values`**: declare up to eight numbers in the shader file, and set them with the `values` prop. When your mod's state changes, call `$.ui.invalidate('ui.render')` to send the new numbers.
554* **The shader file**: write a subset of TypeScript without `while` loops, recursion, or imports from other files. For the full rules and the functions you can call, [get the type definitions with the CLI](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build) and search them for `claude-code/shader`.
555* **The `Svg`**: draw it as a finished picture, because users see it alone when the shader can't run.
556
557#### Fix a backdrop that shows only the `Svg`
558
559Check reduced motion first, because it keeps any shader from running, then these other causes:
560
561* **Reduced motion is on**: if you don't need reduced motion, turn it off in your system settings and set **Motion** to **System** in the Desktop app's **Settings > General**.
562* **The shader file breaks a rule**: in your shell, run `claude plugin validate` on the mod's directory and fix the line the output names.
563* **The shader is too heavy for the GPU**: if `claude plugin validate` prints `needs a fast GPU`, simplify the shader until the output says `runs on any GPU`. Start with the lines the output ranks as costing the most.
564* **The `Svg` holds content that blocks shaders**: replace the `Svg` source with `STILL` from the [`glow` example](#animate-a-backdrop-with-a-shader). If the shader then runs, restore your source without the content that blocks it, such as a lighting filter or `feTile`.
565* **A shader from any mod ran and then stopped**: after the app stops a shader for flashing or running too slowly, it starts no shader for up to five minutes. Keep large changes in brightness or color under three a second, or simplify a slow shader. Then wait five minutes and start a new session.
443 566
444### Change the colors of the Desktop app567### Change the colors of the Desktop app
445 568
510* **Old version**: [update the Desktop app](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab), restart it, and start a new local session in the Code tab. If Claude wrote the mod, ask for it again there.633* **Old version**: [update the Desktop app](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab), restart it, and start a new local session in the Code tab. If Claude wrote the mod, ask for it again there.
511* **Mod not loaded**: if Claude wrote the mod, see when it loads in [Ask Claude for a mod](https://code.claude.com/docs/en/plugins/mods/create.md#ask-claude-for-a-mod). If you wrote it, compare your files and their paths with [Write a colors mod yourself](#write-a-colors-mod-yourself).634* **Mod not loaded**: if Claude wrote the mod, see when it loads in [Ask Claude for a mod](https://code.claude.com/docs/en/plugins/mods/create.md#ask-claude-for-a-mod). If you wrote it, compare your files and their paths with [Write a colors mod yourself](#write-a-colors-mod-yourself).
512* **Refused theme**: ask Claude to run the mod's [`makeColors`](#write-a-colors-mod-yourself) call. If the call throws an error, or its `problems` list has an entry that starts `Desktop won't paint this theme`, have Claude fix the theme. If you installed the mod, send what Claude finds to its author.635* **Refused theme**: ask Claude to run the mod's [`makeColors`](#write-a-colors-mod-yourself) call. If the call throws an error, or its `problems` list has an entry that starts `Desktop won't paint this theme`, have Claude fix the theme. If you installed the mod, send what Claude finds to its author.
513* **Another `$.theme` call**: when any mod in the session calls `$.theme.set` or `$.theme.clear()`, the colors and [backdrop](#put-a-backdrop-behind-the-conversation) from an earlier call disappear. In your own mod, pass `colors` and `backdrop` in the same `$.theme.set` call. Use one mod at a time that sets a theme.636* **Another `$.theme` call**: when any mod in the session calls `$.theme.set` or `$.theme.clear()`, the colors, [backdrop](#put-a-backdrop-behind-the-conversation), [message style](#style-messages-in-the-desktop-app), and [sound](#add-sound-to-a-theme) from an earlier call disappear. In your own mod, pass every part of the theme in the same `$.theme.set` call. Use one mod at a time that sets a theme.
514 637
515### Remove mod colors from the Desktop app638### Remove mod colors from the Desktop app
516 639
530 653
531If the colors are still there, open **Settings** from the Code tab, and search there for `code appearance`. Open the result, and select **Remove colors**.654If the colors are still there, open **Settings** from the Code tab, and search there for `code appearance`. Open the result, and select **Remove colors**.
532 655
656### Style messages in the Desktop app
657
658To give messages in the Desktop app's Code tab their own bubbles, font, and text size, write a mod that calls `$.theme.set` with a `style` object. This requires Claude Code v2.1.329 or later in the Code tab, so [check the version there](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab) first. The terminal, the VS Code extension, and the mobile app show messages without the style.
659
660This mod sets a serif font for messages and puts each message in a rounded bubble. If `$.theme.set` rejects the style, the mod writes the error to the transcript:
661
662```javascript theme={null}
663const style = {
664 Text: { fontFamily: ['serif'], fontSize: 15, lineHeight: 22 },
665 // The corners run top left, top right, bottom right, bottom left
666 UserMessage: { backgroundColor: '#1d5fd1', color: '#ffffff', radius: [18, 18, 4, 18], padding: 12 },
667 AssistantMessage: { backgroundColor: '#e9e9ec', color: '#1c1c1f', radius: [18, 18, 18, 4], padding: 12 },
668}
669
670export function register(on) {
671 on('session.start', async ($, e, next) => {
672 try {
673 await $.theme.set({ style })
674 } catch (error) {
675 $.ui.log(error.message)
676 }
677 return next(e)
678 })
679}
680```
681
682To try the example:
683
684**1. Save the mod**
685
686Save the code as `~/.claude/skills/bubbles/hooks/register.js`. From [Write a mod yourself](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself), save `.claude-plugin/plugin.json` and `hooks/hooks.json` in `~/.claude/skills/bubbles/`, and change `first-mod` to `bubbles` in both files.
687
688**2. Turn off other theme mods**
689
690[Turn off any other mod](#remove-mod-colors-from-the-desktop-app) that calls `$.theme.set`, because each call replaces the whole theme. To use a style and colors together, see [Combine a style with colors or a backdrop](#combine-a-style-with-colors-or-a-backdrop).
691
692**3. Check the style**
693
694Start a new local session in the Code tab and send a message. Your message appears in a blue bubble and Claude's reply in a light gray one, both in a serif font. If nothing changes, see [Fix a missing message style](#fix-a-missing-message-style-in-the-desktop-app).
695
696To take the style off, move `~/.claude/skills/bubbles/` out of `~/.claude/skills/` and start a new session.
697
698#### Combine a style with colors or a backdrop
699
700To use a message style with [colors](#write-a-colors-mod-yourself) or a [backdrop](#put-a-backdrop-behind-the-conversation), pass them all in one call from one mod, as in `$.theme.set({ colors: theme, style })`. Claude Code versions before v2.1.329 reject a call that includes `style` or [`sound`](#add-sound-to-a-theme). To keep your colors and backdrop on those versions, catch the error, log it, and repeat the call without `style` and `sound`.
701
702#### Choose which parts of the conversation to style
703
704Each key in the `style` object you pass to `$.theme.set` names a part of the conversation.
705
706| Key | What it styles | What you can set |
707| :- | :- | :- |
708| `Text` | The words of your messages and Claude's replies, where `UserMessage` or `AssistantMessage` doesn't set the same property | Text properties |
709| `Heading` | Headings in Claude's replies, which otherwise use the reply's font | Text properties |
710| `UserMessage` | Your messages | Text properties, box properties, and `rotate` |
711| `AssistantMessage` | Each block of text in Claude's replies | Text properties, box properties, and `rotate` |
712| `ToolUse` | A tool call's row | `color`, `fontFamily`, and box properties |
713
714Other parts keep the app's look, such as permission prompts, the questions Claude asks in a dialog, code blocks, and the prompt box.
715
716Write sizes as numbers of points, such as `lineHeight: 22`. For the format and range of every value, see `ThemeStyle` in [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build).
717
718* **Text properties**: `color`, `fontFamily`, `fontSize`, `fontWeight`, `italic`, `letterSpacing`, and `lineHeight`. Write `fontFamily` as a one-item list, such as `['serif']`. The item must be `sans`, `serif`, `mono`, `cursive`, or `code`, and `$.theme.set` rejects any other value. Use `code` for the app's code font.
719* **Box properties**: `backgroundColor`, `radius`, `borderColor`, `borderWidth`, `shadow`, `fill`, and padding such as `padding` or `paddingTop`. Write a shadow as `{ x: 0, y: 2, blur: 8, color: 'rgba(0, 0, 0, 0.15)' }`. Use `fill` to draw a gradient or a vector drawing behind the text, as in `{ gradient: { stops: ['#dbe8ff', '#c4d6f5'] } }`.
720* **`rotate`**: the number of degrees to tilt a message, from `-3` to `3`
721
722To vary the bubbles, set `UserMessage` or `AssistantMessage` to a list of up to four objects. Each message gets one of the objects, in no set order, and keeps it.
723
724#### Set message colors for light mode and dark mode
725
726To give messages different colors in light mode and dark mode, add these message colors to `inputs.light` and `inputs.dark` in the theme that [`makeColors`](#write-a-colors-mod-yourself) returns:
727
728* **Your messages**: `bg-user-message` for the bubble and `text-user-message` for the text
729* **Claude's replies**: `bg-assistant-message` for the bubble and `text-assistant-message` for the text
730
731Before you add them to a mod that passes `style`, remove `color` and `backgroundColor` from the matching `UserMessage` or `AssistantMessage`, because those properties take precedence over message colors.
732
733This example colors your messages in the `paper` mod from [Write a colors mod yourself](#write-a-colors-mod-yourself). In that mod's `register.js`, add these lines between the `makeColors` call and the `register` function:
734
735```javascript theme={null}
736Object.assign(theme.inputs.light, { 'bg-user-message': '#d9c4a0', 'text-user-message': '#2a241d' })
737Object.assign(theme.inputs.dark, { 'bg-user-message': '#4a3a2b', 'text-user-message': '#f0e7d7' })
738```
739
740Put `paper` under `~/.claude/skills/`, and move other theme mods, such as `bubbles`, out of that directory. Start a new local session and send a message. Your bubble is tan in light mode and brown in dark mode. If it isn't, see [Fix missing mod colors](#fix-missing-mod-colors-in-the-desktop-app) and [Fix a missing message style](#fix-a-missing-message-style-in-the-desktop-app).
741
742#### Fix a missing message style in the Desktop app
743
744If all or part of a message style doesn't appear in the Code tab, check for these causes:
745
746* **Mod not loaded**: [find out why the mod does nothing](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing)
747* **Rejected call**: catch the error from `$.theme.set` and write it to the transcript, as the [example](#style-messages-in-the-desktop-app) does. If the error includes `theme.set does not know the attribute "style"`, [update Claude Code](https://code.claude.com/docs/en/plugins/mods/overview.md#turn-mods-on-or-off) in the app that shows the error. If it names a property, as in `style.Text.fontSize is a number of points, 11 to 28`, change that property's value.
748* **Another `$.theme` call**: if any mod in the session calls `$.theme.clear()`, or calls `$.theme.set` without your `style`, the style disappears. In your own mod, [pass the whole theme in one call](#combine-a-style-with-colors-or-a-backdrop). Turn off any other mod that sets a theme.
749* **Low contrast**: when text has less than 3:1 contrast with its background, that message, heading, or tool row shows in the app's own colors. `$.theme.set` reports no error. Pick colors that are further apart, and check both light mode and dark mode.
750* **Backdrop**: over a [backdrop](#put-a-backdrop-behind-the-conversation), a text color shows only on a background that's solid or nearly solid. Set a solid `backgroundColor` on `UserMessage`, `AssistantMessage`, and `ToolUse` wherever you color their text, including through `Text` or `Heading`.
751* **Accessibility settings**: with higher contrast turned on in the app or the operating system, messages show without the style. With an accessibility font such as OpenDyslexic, messages keep that font. To see the whole style, turn these settings off.
752* **Open prompt**: a new style waits while a permission prompt or a question from Claude is on screen. Answer it to see the style.
753
754### Add sound to a theme
755
756To give your theme background sound and short sounds for events in the Desktop app's Code tab, pass `sound` to [`$.theme.set`](https://code.claude.com/docs/en/plugins/mods/reference#mods-api-methods). `sound` requires Claude Code v2.1.329 or later in the Code tab, so [check the version there](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab) first. The terminal, the VS Code extension, and the mobile app play no theme sound.
757
758You describe each sound as layers of tones and noise, with no audio file, and the Desktop app makes the audio.
759
760This mod sets dark mode, plays soft noise in the background, and plays three bell notes when Claude finishes a turn:
761
762```javascript theme={null}
763// The rest of the theme, which still works without sound
764const look = { overrideColorScheme: 'dark' }
765
766const sound = {
767 ambience: {
768 // A layer with drone: true plays without a break
769 // A layer with scatter plays now and then
770 // gain is how loud a layer is, from 0 to 1
771 layers: [{ wave: 'brown', drone: true, gain: 0.2 }],
772 },
773 cues: {
774 done: {
775 // step is the seconds from one note to the next
776 layers: [{ wave: 'bell', notes: ['C5', 'E5', 'G5'], step: 0.15, gain: 0.3 }],
777 },
778 },
779}
780
781export function register(on) {
782 on('session.start', async ($, e, next) => {
783 try {
784 await $.theme.set({ ...look, sound })
785 } catch (error) {
786 // A refused call sets nothing, so set the theme again without sound
787 $.ui.log(error.message)
788 await $.theme.set(look)
789 }
790 return next(e)
791 })
792}
793```
794
795For the other waves, fields, and ranges, see `ThemeSound` in [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build). To hear the example:
796
797**1. Start a session**
798
799Put the code in a [mod](https://code.claude.com/docs/en/plugins/mods/create.md#write-a-mod-yourself), and save the mod's directory [under `~/.claude/skills/`](https://code.claude.com/docs/en/plugins/create#scaffold-a-plugin-that-loads-every-session) so that it loads when you start a session. In the Code tab, send a first message to [start a local session](https://code.claude.com/docs/en/desktop.md#start-a-session). If no speaker button appears in the session's title bar, see [Fix a missing speaker button](#fix-a-missing-speaker-button).
800
801**2. Turn on theme sound**
802
803If the speaker button is crossed out, select it. The three notes play once to confirm that sound is on, and the noise fades in. To change the volume or turn off the noise, open the menu beside the button.
804
805**3. Hear the cue**
806
807Send another message. The three notes play when Claude finishes.
808
809#### When each theme sound plays
810
811Theme sound is off until the user turns it on with the speaker button. It then stays on for other sessions and themes on that device until the user turns it off, signs out, or switches accounts. Choose a `gain` that suits a user who hears your theme as soon as it loads.
812
813The Desktop app plays each sound by itself at these moments, and a mod can't trigger one:
814
815| Sound | When it plays |
816| :- | :- |
817| `ambience` | While the session's window has focus. It pauses after 10 minutes with no input and resumes at the next input. |
818| `cues.send` | The user sends a message |
819| `cues.tool` | Claude starts a tool call |
820| `cues.compact` | The conversation is compacted |
821| `cues.done` | Claude finishes a turn, unless the user stopped it or queued another message |
822| `cues.ask` | A permission prompt or a question appears |
823| `cues.error` | A turn ends in an error |
824| `cues.click` | The user clicks the background where no message, control, or panel covers it |
825
826When the user turns on sound or picks a volume, they also hear one cue, the first the theme has in this order: `send`, `done`, `tool`, `compact`, `ask`, `error`.
827
828Expect fewer of the table's sounds during an unanswered prompt, during speech, and in a window without focus. To hear all of them again:
829
830* **A permission prompt or a question is waiting**: answer it. Until then, only `cues.ask` can play.
831* **Dictation, a voice call, or a reply read aloud is in progress**: end it. Until then, the ambience and cues stay silent.
832* **The window doesn't have focus**: click in the window. Until then, only `cues.done` can play.
833
834#### Fix a missing speaker button
835
836If the session's title bar shows no speaker button, check your version, whether the mod loaded, and the `$.theme` calls in the session:
837
838* **Old version**: if `/status` in the Code tab shows a version before v2.1.329, [update the Desktop app](https://code.claude.com/docs/en/desktop.md#claude-code-version-in-the-code-tab) and start a new local session. On those versions, the call fails with an error such as `theme.set does not know the attribute "sound"`.
839* **Mod not loaded**: follow [Find out why a mod does nothing](https://code.claude.com/docs/en/plugins/mods/troubleshoot.md#find-out-why-a-mod-does-nothing).
840* **Value out of range**: the call fails, so with the example's `catch` block the theme loads without sound. Find the error that the example logs in the transcript, and fix the field it names, as in `sound.cues.done.layers[0].gain is a number, 0 to 1`.
841* **Another `$.theme` call**: when any mod makes a later `$.theme.set` call without `sound`, or calls `$.theme.clear()`, the sound and the button disappear. In your own mod, pass `sound` in the same call as the rest of the theme. Turn off any other mod that sets a theme.
842
533## Build a tree from elements843## Build a tree from elements
534 844
535What a `ui.render` hook returns is an element tree: a description of what to draw, made of boxes, text, and controls nested inside each other.845What a `ui.render` hook returns is an element tree: a description of what to draw, made of boxes, text, and controls nested inside each other.
613| `Button` | A control that calls `onPress` | Everywhere |923| `Button` | A control that calls `onPress` | Everywhere |
614| `Link`, `Code`, `Markdown` | A link with `href` and an optional `label`, a code block, and text formatted the way Claude's replies are. `Markdown` takes its content in a `text` prop, not in `children`, and needs a `key` when you pass `onLinkPress`. | Everywhere |924| `Link`, `Code`, `Markdown` | A link with `href` and an optional `label`, a code block, and text formatted the way Claude's replies are. `Markdown` takes its content in a `text` prop, not in `children`, and needs a `key` when you pass `onLinkPress`. | Everywhere |
615| `Input`, `Select` | A text field and a dropdown | Terminal, Desktop, VS Code |925| `Input`, `Select` | A text field and a dropdown | Terminal, Desktop, VS Code |
926| `Shader` | A [backdrop drawn on the GPU](#animate-a-backdrop-with-a-shader) over an `Svg` | Desktop |
616| `Svg` | An SVG document | Desktop, VS Code |927| `Svg` | An SVG document | Desktop, VS Code |
617| `Client` | A region drawn by a second file of yours, for animation and pointer input. That file gets no mods API. It reaches your hooks by posting data, which arrives as a `ui.message` event. If it fails to load, draw, or run, your hooks receive a [`ui.fault`](https://code.claude.com/docs/en/plugins/mods/reference#interface) event. | Terminal, Desktop |928| `Client` | A region drawn by a second file of yours, for animation and pointer input. That file gets no mods API. It reaches your hooks by posting data, which arrives as a `ui.message` event. If it fails to load, draw, or run, your hooks receive a [`ui.fault`](https://code.claude.com/docs/en/plugins/mods/reference#interface) event. | Terminal, Desktop |
618| `Raster`, `Image` | A [grid of colored cells](#draw-a-grid-of-colored-cells), and a picture | Terminal |929| `Raster`, `Image` | A [grid of colored cells](#draw-a-grid-of-colored-cells), and a picture | Terminal |