Install
Run the setup command, let your coding agent set it up, or add it yourself. All four load the same panel.
Run this in your prototype’s folder. It finds the right file (your app’s entry file, or index.html for a plain page) and shows the line to add. It changes nothing yet.
npx twiddle-panel init
Happy with it? Run it again with --write to add the line for you. It never adds it twice.
npx twiddle-panel init --write
With a build tool it loads the panel only while developing (the tokens stay in every build). Add --always to load it in every build too, for shared preview links, or --file path/to/file to choose the file yourself. With a build tool it reminds you to run npm install -D twiddle-panel. For Next.js it prints a small client component to paste instead. Needs Node.js.
Paste this into Claude Code, Cursor or any agent working on your prototype. It works out how your project runs, adds Panel the right way and checks that the panel appears.
Install Panel by Twiddle (the twiddle-panel package) in this prototype. It's a small panel for tweaking the design tokens live, used only while developing.
1. Work out how this project runs, then add Panel the matching way:
- With a build tool (a package.json and a dev server such as Vite, Next.js or Astro): install it with this project's package manager, for example `npm install -D twiddle-panel`. Then add these two lines to the app's entry file, above the project's own style imports:
import 'twiddle-panel/tokens.css';
if (import.meta.env.DEV) import('twiddle-panel');
The first line keeps the token defaults in every build; the second loads the panel only while developing. If the project doesn't use Vite, replace import.meta.env.DEV with its own development check. With server rendering (such as Next.js), make sure the second import runs only in the browser, for example in a client component's effect.
- Plain HTML with no build step: add this before </body>:
<script src="https://cdn.jsdelivr.net/npm/twiddle-panel@0.9.0/dist/twiddle.js" defer></script>
It adds the token defaults itself, ahead of the page's own styles.
If the project already uses the old @theoldpixel/twiddle package, replace it with twiddle-panel.
2. Keep the panel out of production builds. Don't change anything else.
3. Run the prototype and check that the Panel button (a dark disc with a switch knob) appears in the bottom-right corner (Alt+T opens the panel).
4. Tell me what you changed. Then check whether the styles use the --twd-* tokens. If they don't, the panel won't change anything yet: say so, and point me to the "Style with tokens" step at https://panel.twiddle.in/#tokens.
For projects you run with npm run dev (Vite, Next.js, Astro…). Run this in your project folder:
npm install -D twiddle-panel
Then add one line to your app’s entry file, for example main.js. The panel adds the token defaults itself, ahead of your own styles.
import 'twiddle-panel';
To keep the panel out of your production build, use these two lines instead. The tokens stay in every build; the panel loads only while developing.
import 'twiddle-panel/tokens.css';
if (import.meta.env.DEV) import('twiddle-panel');
In a framework without import.meta.env.DEV, use your own dev check, such as process.env.NODE_ENV !== 'production'.
For a static HTML file with no build step. Nothing to install: paste this before </body>. It adds the token defaults itself, ahead of your own styles.
<script src="https://cdn.jsdelivr.net/npm/twiddle-panel@0.9.0/dist/twiddle.js" defer></script>
This link pins version 0.9.0, so your page won't change when Panel updates. Change the number to upgrade.
Style with tokens
The panel changes the --twd-* CSS variables. Anything you style with them responds to the panel; anything with fixed values stays as it is. Let your coding agent convert your styles, or write them yourself.
Paste this into Claude Code, Cursor or any agent working on your prototype. It replaces fixed values with tokens and keeps your current look as the starting point.
Convert this prototype's styles to use the Panel design tokens (the --twd-* CSS custom properties from twiddle-panel), so the panel can tweak them live.
1. Keep the current look. In a :root rule loaded after twiddle-tokens.css, set each token below to the value this project already uses (for example, if buttons use #0f766e, set --twd-primary: #0f766e). Only set the tokens the project actually needs.
2. Replace fixed values in component styles with var(--twd-…). Map each value to the closest token by role:
- Fonts: --twd-font-heading, --twd-font-body
- Text sizes: --twd-text-xs, -sm, -base, -lg, -xl, -2xl, -3xl; line height: --twd-leading-tight, --twd-leading-normal
- Font weights: --twd-weight-heading (headings, big numbers), --twd-weight-strong (buttons, labels, emphasis)
- Colours: --twd-bg (page), --twd-surface (cards, inputs), --twd-surface-raised (menus, popovers), --twd-text, --twd-text-muted, --twd-border, --twd-primary, --twd-primary-hover, --twd-on-primary (text on primary), --twd-focus, --twd-success, --twd-warning, --twd-danger
- Buttons, inputs, chips: --twd-radius-control, --twd-control-height, --twd-control-pad-x
- Cards, menus, modals: --twd-radius-container, --twd-border-width-container
- Main button and default card, preferred where they fit: --twd-button-bg, --twd-button-fg, --twd-button-border, --twd-button-hover (hover background); --twd-card-bg, --twd-card-border, --twd-card-shadow
- Borders: --twd-border-width
- Spacing (padding, margin, gap): --twd-space-1 to --twd-space-8 (4, 8, 12, 16, 24, 32, 48, 64px)
- Layout roles, preferred where they fit: --twd-page-pad (side padding of the page), --twd-section-gap (between page sections), --twd-card-pad (inside cards, menus, modals), --twd-card-gap (between items in a card), --twd-control-gap (between buttons, chips, inputs in a row)
- Shadows: --twd-shadow-sm, --twd-shadow-md, --twd-shadow-lg
3. Leave values that don't match a role as they are (layout widths, one-off illustrations, icon sizes). Don't invent new --twd-* tokens.
4. Don't change the layout or how the page looks; after the change it should look the same until someone uses the panel.
5. When done, list the files you changed and any values you left fixed, with the reason.
Use the tokens wherever you want a knob to have an effect:
h1, h2, h3 {
font-family: var(--twd-font-heading);
font-weight: var(--twd-weight-heading);
}
.button {
height: var(--twd-control-height);
padding: 0 var(--twd-control-pad-x);
border-radius: var(--twd-radius-control);
border: var(--twd-border-width) solid var(--twd-button-border);
background: var(--twd-button-bg);
color: var(--twd-button-fg);
font-family: var(--twd-font-body);
font-weight: var(--twd-weight-strong);
}
.button:hover { background: var(--twd-button-hover); }
.card {
background: var(--twd-card-bg);
border: var(--twd-border-width-container) solid var(--twd-card-border);
border-radius: var(--twd-radius-container);
box-shadow: var(--twd-card-shadow);
padding: var(--twd-card-pad);
}
To use your own defaults, redefine any token in your stylesheet after the Panel tokens. The panel then starts from your values:
:root {
--twd-primary: #0f766e;
--twd-radius-control: 6px;
--twd-font-heading: "Fraunces", Georgia, serif;
}
See the token reference for the full list.
Use the panel
Open it with the Panel button in the bottom-right corner, or Alt T (Option T on a Mac). The panel opens beside the button, and short messages such as “Link copied” appear just above it. Tabs along its top switch between areas; one row along its bottom holds the actions for the whole page. Try it on this sample:
Sample components
Select one of these with Pick (the arrow) to change it on its own.
| Control | What it does |
|---|---|
| Overview tab | The Character pad: drag up for spacious, down for compact; left for Subtle, right for Bold (font weights, borders, corners and shadows). Below it, a summary of the current look; each row opens its tab. |
| Colour tab | Pick one of four themes, then fine-tune with the Tailwind palette: a colour family and shade for the primary, a grey family for the neutrals. A custom hex still works. Mode switches Light and Dark. |
| Type tab | Font pairings, base size and scale. |
| Spacing tab | Density. Layout roles points page padding, section gaps, card padding and similar roles at a different spacing step. |
| Shape tab | Buttons: Style (Solid, Soft, Outline, Ghost), corners and size. Cards: Style (Filled, Outlined, Elevated, Tinted), corners, Fill (None, Surface, Raised, Tinted) and borders. |
| Shadows tab | Shadow style and intensity. |
| … tokens | Each tab ends with its tokens as rows, so you can set any one exactly. A token you set by hand is marked Custom and stays put when you move the broad knobs; reset it to undo that. |
| Linked settings | Tabs stay in step. When the Character pad changes something another tab owns (corners, borders, shadows, weights), that tab shows the real value and says “from Character”. Spacing between two presets reads, for example, “Between Regular and Comfy”. |
| Pick (arrow) | Starts selection mode: click an element, and every tab (the Character pad included) now changes just that element, until you press Pick again. Switch to All .class to change every element like it. |
| Compare (half circle) | Hold it, or press Alt C, to see the original page. |
| Copy link | Copies a link to this exact version. Settings live in the ?twd= part of the address. |
| Reset | Back to the page’s own defaults. Undo brings it back. |
| Move | Drag the Panel button anywhere: it settles into the nearest corner and keeps its distance from the edges, and the panel opens on the side away from the edge. With the button focused, the arrow keys nudge it 1px (Shift for 10px). Double-click it to put it back in the bottom-right corner. Your spot is remembered on that site. |
| Minimise (chevron) | At the end of the tabs. Shrinks the panel to just its tabs, beside the Panel button. Click a tab or the chevron to open it again. The Panel button closes the panel altogether. |
| Undo / Redo | In the bottom row, or ⌘ Z / ⇧ ⌘ Z while the panel has focus. |
| Changes (count) | The number in the bottom row. Opens a side panel next to the main one, listing every tweak with the token values before and after. Remove any one with ×. |
To decide what “all like this” means for an element, add data-twd="name" to it. Panel groups by that name instead of the class.
Hand off to your agent
Tweaks in the panel live only in the link. To make them permanent, press Copy prompt. Panel writes a prompt for your coding agent (Claude Code, Cursor or similar) that lists:
- token changes for the whole page, old value → new value
- changes for every element sharing a class
- single-element changes, described so the agent can find them
- any colour pairs that fail WCAG AA contrast
Paste it into the agent working on your prototype. Use the arrow next to Copy prompt to choose between Preview before copying and Copy without preview.
Token reference
Every --twd-* token, its default, and the panel section that changes it
| Token | Default | Where in the panel |
|---|---|---|
--twd-font-heading, --twd-font-body | System sans | Type › Fonts |
--twd-text-xs … --twd-text-3xl | 0.694rem … 2.074rem (1.2 scale) | Type › Base size, Scale |
--twd-leading-tight, --twd-leading-normal | 1.2, 1.5 | Type › Type tokens |
--twd-weight-heading (headings, big numbers), --twd-weight-strong (buttons, labels, emphasis) | 600, 600 | Overview › Character (Subtle ↔ Bold); Type › Type tokens |
--twd-primary, --twd-primary-hover, --twd-on-primary, --twd-focus | #4f46e5, #4338ca, #ffffff, #6366f1 | Colour › Theme, Primary |
--twd-bg, --twd-surface, --twd-surface-raised | #fafafa, #ffffff, #ffffff | Colour › Theme, Neutral, Mode |
--twd-text, --twd-text-muted, --twd-border | #18181b, #71717a, #e4e4e7 | Colour › Theme, Neutral, Mode; Overview › Character (Bold darkens muted text and borders) |
--twd-success, --twd-warning, --twd-danger | #16a34a, #d97706, #dc2626 | Colour › Colour tokens |
--twd-radius-control | 8px | Shape › Buttons › Corners; Overview › Character |
--twd-control-height, --twd-control-pad-x | 40px, 16px | Shape › Buttons › Size; the padding also under Spacing › Layout roles |
--twd-radius-container | 12px | Shape › Cards › Corners; Overview › Character |
--twd-border-width, --twd-border-width-container | 1px | Shape › Cards › Borders (cards); Overview › Character |
--twd-button-bg, --twd-button-fg, --twd-button-border, --twd-button-hover (main button) | primary, on-primary, transparent, primary-hover | Shape › Buttons › Style |
--twd-card-bg, --twd-card-border, --twd-card-shadow (default card) | surface, border, shadow-sm | Shape › Cards › Style, Fill |
--twd-space-1 … --twd-space-8 | 4, 8, 12, 16, 24, 32, 48, 64px | Overview › Character (up/down); Spacing › Density |
--twd-page-pad (side padding of the page) | space-5 (24px) | Spacing › Layout roles |
--twd-section-gap (between page sections) | space-6 (32px) | Spacing › Layout roles |
--twd-card-pad (inside cards, menus, modals) | space-5 (24px) | Spacing › Layout roles |
--twd-card-gap (between items in a card) | space-2 (8px) | Spacing › Layout roles |
--twd-control-gap (between buttons, chips, inputs in a row) | space-3 (12px) | Spacing › Layout roles |
--twd-shadow-sm, --twd-shadow-md, --twd-shadow-lg | Soft shadows | Shadows › Style, Intensity; Overview › Character |
Troubleshooting
The panel opens, but nothing on my page changes
Your CSS uses fixed values. Replace them with var(--twd-…) tokens (see step 2).
Panel (twiddle-panel) opens on this prototype, but changing its settings has no effect on the page. Find out why and fix it.
First check that Panel loads: `import 'twiddle-panel'` (or `import 'twiddle-panel/tokens.css'`) in the entry file, or the twiddle-panel <script> tag. Panel adds its token defaults first in <head>, so the project's own styles still win.
Then convert the styles to use the tokens:
{{TOKENS_PROMPT}}
The Panel button doesn’t appear
Check that the script or import runs: with a build tool, the import.meta.env.DEV check only passes on the dev server. Then press Alt T in case the panel is closed.
Panel (twiddle-panel) should show the Panel button (a dark disc with a switch knob) in the bottom-right corner of this prototype while it runs in development, but the button doesn't appear. Find out why and fix it. Check, in order:
1. The package is installed: twiddle-panel is in package.json (devDependencies is fine) and in node_modules. If the project uses the old @theoldpixel/twiddle package, replace it with twiddle-panel.
2. The app's entry file loads it, either `import 'twiddle-panel';` or, to keep it out of production builds:
import 'twiddle-panel/tokens.css';
if (import.meta.env.DEV) import('twiddle-panel');
If this project doesn't use Vite, replace import.meta.env.DEV with this framework's own development check. In frameworks with server rendering (such as Next.js), make sure the import runs in the browser, for example inside a client component's effect.
3. For a plain HTML page: the <script src="https://cdn.jsdelivr.net/npm/twiddle-panel@0.9.0/dist/twiddle.js" defer></script> tag is present, and nothing (such as a Content Security Policy) blocks cdn.jsdelivr.net.
4. The browser console shows no errors from Panel.
Keep Panel out of production builds. When done, tell me what was wrong and what you changed.
A picked element lost its tweaks after I changed the page
Single-element tweaks find the element by its position in the page. Give it an id or a data-twd name before tweaking, so it can be found again.
This prototype uses Panel (twiddle-panel) to tweak individual elements. Panel finds a picked element by its position in the page, so tweaks get lost when the markup changes. Give elements stable hooks so tweaks survive edits: 1. Give each important one-off element a unique, descriptive id (for example id="hero-cta" or id="signup-email"). Panel uses the id to find a single element. 2. Give each reusable component a data-twd attribute naming the component (for example data-twd="primary-button", data-twd="text-input", data-twd="card"). Panel uses it to apply a tweak to every element of that kind. 3. Only add attributes. Don't change styles, classes or structure, and don't rename ids that scripts or links already rely on. When done, list the ids and data-twd names you added.