Twiddle

Tweak a prototype’s design system live, then share the exact version.

Twiddle is a small panel you drop into any HTML prototype. Expose type, colour, shape, density and depth as knobs. Reviewers explore them, copy a link to what they like, and hand the result to a coding agent.

This page runs Twiddle. Open the dial in the bottom-right corner (or press Alt T) and change anything: these docs restyle as you go.

Step 1

Install

Pick the setup that matches your prototype. Both load the same panel.

For projects you run with npm run dev (Vite, Next.js, Astro…). Run this in your project folder:

Terminal
npm install -D @theoldpixel/twiddle

Then add two lines to your app’s entry file, for example main.js:

main.js
import '@theoldpixel/twiddle/tokens.css';
if (import.meta.env.DEV) import('@theoldpixel/twiddle');

The import.meta.env.DEV check keeps the panel out of your production build. In a framework without it, use your own dev check, such as process.env.NODE_ENV !== 'production'.

Step 2

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.

Prompt
Convert this prototype's styles to use the Twiddle design tokens (the --twd-* CSS custom properties from @theoldpixel/twiddle), so the Twiddle 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
   - 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
   - Borders: --twd-border-width
   - Spacing (padding, margin, gap): --twd-space-1 to --twd-space-8 (4, 8, 12, 16, 24, 32, 48, 64px)
   - 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.

See the token reference for the full list.

Step 3

Use the panel

Open it with the dial in the corner, or Alt T (Option T on a Mac). Try it on this sample:

Sample components

Pick one of these with the crosshair to change it on its own.

ControlWhat it does
SectionsTypography, Colour, Buttons, Cards, Density and Depth change the whole page.
Pick (crosshair)Click an element to tweak only that element. The panel shows just the settings it uses. 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 linkCopies a link to this exact version. Settings live in the ?twd= part of the address.
ResetBack to the page’s own defaults. Undo brings it back.
Undo / RedoIn the footer, or ⌘ Z / ⇧ ⌘ Z while the panel has focus.
ChangesLists 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. Twiddle groups by that name instead of the class.

Step 4

Apply the changes

Tweaks in the panel live only in the link. To make them permanent, press Apply. Twiddle 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 Apply to choose between Preview, then copy and Copy immediately.

The panel is a design tool. Load it while developing or in shared prototype links, not in a production site.

Token reference

Every --twd-* token, its default, and the panel section that changes it
TokenDefaultPanel section
--twd-font-heading, --twd-font-bodySystem sansTypography › Fonts
--twd-text-xs … --twd-text-3xl0.694rem … 2.074rem (1.2 scale)Typography › Base size, Scale
--twd-leading-tight, --twd-leading-normal1.2, 1.5—
--twd-primary, --twd-primary-hover, --twd-on-primary, --twd-focus#4f46e5, #4338ca, #ffffff, #6366f1Colour › Brand
--twd-bg, --twd-surface, --twd-surface-raised#fafafa, #ffffff, #ffffffColour › Neutral, Mode
--twd-text, --twd-text-muted, --twd-border#18181b, #71717a, #e4e4e7Colour › Neutral, Mode
--twd-success, --twd-warning, --twd-danger#16a34a, #d97706, #dc2626—
--twd-radius-control8pxButtons › Corners
--twd-control-height, --twd-control-pad-x40px, 16pxButtons › Size
--twd-radius-container12pxCards › Corners
--twd-border-width, --twd-border-width-container1pxCards › Border
--twd-space-1 … --twd-space-84, 8, 12, 16, 24, 32, 48, 64pxDensity › Spacing
--twd-shadow-sm, --twd-shadow-md, --twd-shadow-lgSoft shadowsDepth › Style, Intensity

Troubleshooting

The panel opens, but nothing on my page changes

Your CSS uses fixed values. Replace them with var(--twd-…) tokens (see step 2).

The dial 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.

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.