A component beside the code that makes it, where every value is a control. Drag a number, switch a boolean, type over the text. Ask for it in your chat, or put it in your Storybook and docs.
<Button
variant=
size=
radius={8}
disabled={}
>
</Button>- In the chat, with your agent
Review an agent's work
Try the API it wrote in the chat, before it lands in your codebase.
Say what broke
Break it, then say so. The agent already has the code as you left it.
- In your codebase, as a package
Code as docs you can try
Every prop is a control, and the docs never drift.
Learn by changing it
Explain a layout or an effect with something to play with.
Show it in the chat
Ask your agent for a component and say “show it in Component Code”. It writes the component, and the chat shows it running beside the code that uses it, with every value a control. Change a value until something breaks, then just say what is wrong. The agent already has the code as you left it.
Build me a toggle with a label and a disabled state. Show it in Component Code.
<Toggle
label=
checked={}
disabled={}
/>Here it is. Switch it, or change its label and state in the code.
Add it to your agent:
Add the component-code MCP server to this agent. It runs with the command npx -y @fabiocv/component-code-mcp. Add it the way this agent adds MCP servers, then tell me if I need to restart for its tools to load.
claude mcp add component-code -- npx -y @fabiocv/component-code-mcp{
"mcpServers": {
"component-code": {
"command": "npx",
"args": ["-y", "@fabiocv/component-code-mcp"]
}
}
}code --add-mcp '{"name":"component-code","command":"npx","args":["-y","@fabiocv/component-code-mcp"]}'https://mcp-ui-tools.fabio.cv/component-code/mcpThe component can import React and nothing else, and the code that uses it is plain JSX: elements, props and text. A component keeps any state inside itself.
Put it in your docs
One component, 8.1 kB gzipped, with no dependencies beyond React. Give it your components in scope and the code renders as its own preview, so your docs cannot drift from what they show.
npm install @fabiocv/component-code<Badge tone= count={3}>
</Badge>import { ComponentCode } from '@fabiocv/component-code';
import { Badge } from './Badge';
# Badge
<ComponentCode
interactive
scope={{ Badge }}
controls={{ tone: ['neutral', 'success', 'warning'] }}
code={`
<Badge tone="success" count={3}>
Live
</Badge>
`}
/>It reads the code rather than running it: elements, props, text, strings, numbers, booleans, lists, objects and the names in scope. Anything else says why in place of the preview. For code with a hook, pass the preview as children.
| Prop | What it sets |
|---|---|
code | The code as it is written. The blank lines around it and its shared indent are dropped. |
scope | What the code can name: your components and values. With it, the preview is the code itself, rendered. |
interactive | Makes each string, number, boolean and line of text in the code a control. |
controls | How a prop is changed, by its name or by Element.prop: a list of options, { min, max, step } for a number, or false to keep it as written. |
onChange | Called with { prop, value, code } as the reader changes a value. |
children | The preview, for code that cannot run from its text, such as code with a hook. |
file | The file named in the code's tab. Code when left out. |
theme | light or dark. Without it, the page's color-scheme decides. |
note | A line shown from an info icon beside reset, once the reader changes a value. |
Or plain HTML, CSS and JS
For a canvas, an SVG or anything without React, import it from @fabiocv/component-code/html and give it files. They run together in a sandboxed frame, a tab for each, and the values you name in controls become controls. It is 8.1 kB gzipped.
<canvas></canvas>A CSS value changes as you drag it, so a script that reads custom properties each frame follows along. A change to the HTML or JS runs the page again. Name a value by its attribute, as r or circle.r, its CSS property or custom property, or the JS const it sets. In the chat, ask for plain HTML, CSS and JS.
What to ask for
Copy a prompt, then make it yours.
Try it before you build it
See a component working, and change it, before any of it is in your codebase.
Build me a pricing card with a plan name, a price, a list of features and a highlighted state. Show it in Component Code.
Tune the numbers
Drag sizes, durations and spacing until it feels right, then copy the code.
Make a progress ring with its size, stroke width and value as numbers. Show it in Component Code so I can drag them.
Look at a component from your repo
Bring a component into the chat to try its props, without running the app.
Read src/components/Avatar.tsx and show it in Component Code with its sizes as options and its name as text.
Learn by changing it
Explain a layout or an effect with something to play with, not only words.
Explain CSS flexbox with a small component in Component Code where I can change the direction, the alignment and the gap.
Check the edge cases
Type a long name, an empty one or an emoji, and see where it breaks.
Show our Tag in Component Code with its label as text, so I can try long labels, empty ones and emoji.
Document your design system
Have your agent write docs with live examples that cannot drift from the code.
Write a Storybook MDX page for our Badge that uses ComponentCode from @fabiocv/component-code, with its tones as options and its count as a number.
What changed
0.1.0Unreleased
@fabiocv/component-code
ComponentCodeshows a component beside the code that makes it. Withscopethe preview is rendered from the code, so the two cannot differ.childrensets the preview for code that cannot run from its text.interactiveturns each string, number, boolean and line of text in the code into a control: numbers drag and step with the arrow keys, booleans switch, and text is typed in place.controlsturns a prop into options picked from a menu, or sets a number's range and step.- Copy and reset, line numbers and syntax colours.
- Light and dark, from the page's
color-schemeor fromtheme. noteshows a line from an info icon beside reset, once the reader changes a value.@fabiocv/component-code/htmlruns HTML, CSS and JS beside their code, with a tab for each file. The values named incontrolsbecome controls: CSS changes in place, and HTML and JS run the page again.
@fabiocv/component-code-mcp
show_in_component_codeshows a component in the chat in Component Code, as an MCP App.show_html_in_component_codeshows HTML, CSS and JS running in the chat.- As the reader changes a value, the agent gets the code as it now is, and what the preview threw, with their next message, in hosts that take model context. An info icon tells the reader the chat sees this state.
- Runs over stdio with
npx @fabiocv/component-code-mcp, and over HTTP athttps://mcp-ui-tools.fabio.cv/component-code/mcp.