# Reskin — a new appearance, the same app

> look like…

Source: https://good.vibes.diy/docs/reference/reskin

When the person describes how the app should LOOK — "make it look like a 90s
Mac app", "make it feel like a newspaper", "chopped and screwed", "Y2K",
"like Stripe's dashboard", a font, square black borders, a texture, a marquee —
the app keeps its look's components, its logic and its Look tab, and wears that
appearance on top of them. Every `Card`, `Button`, `RowCard` and `Heading`
stays exactly where it is; what changes is how they are drawn.

This works on every look that shares the component surface (the default look today,
and the looks built on its API): the same tokens, the same hook classes, the same
technique.

- Colour, a catalogue font or spacing alone is the Look tab (`set_app_style`);
  it needs no build.
- A style the person BRINGS — a brand guide, pasted CSS or tokens, Material 3,
  a screenshot to copy — is the `match-style` skill, which replaces the
  components with the app's own and makes its `THEME_CSS` the app's one look,
  in this skin's place. A build that stays on this skill for it (a palette and
  fonts pasted onto a reskinned app) writes a new skin from that design in this
  string's place, as step 3 says; either way the app wears the brought design
  alone.
- Everything between — a mood, a named style, a site named with nothing
  supplied — is a reskin.

## The technique

**1. One wrapper re-scopes the look's tokens.** The whole app renders inside
one root element carrying `data-reskin`, and the skin sets the look's own
tokens on `[data-reskin]`, never on `:root`. The served look writes its tokens
on `:root` with `!important`; a nearer ancestor wins for everything inside it,
so the wrapper's values are the ones every component reads.

The tokens: `--bg --surface --ink --text-secondary --purple --on-accent
--orange --info --up --down --idle --warn` (colour), `--r-card --r-control
--r-pill` (corners), `--lip --lip-row` (the cushion's edge), `--font-family`,
`--s1` … `--s7` (spacing), `--ui-paper` (the disc behind a status icon), and
the composite surfaces `--ui-card --ui-row --ui-row-hover --ui-control
--ui-control-active --ui-field --ui-field-focus --ui-blob` (a row's hover lift
is `--ui-row-hover`, an icon tile is `--ui-blob`). A composite is resolved where
it is declared, so a skin that changes the shadows or the edge re-declares every
one of those composites on the wrapper too (`none` for a flat skin):
a composite the skin leaves out keeps the look's own shadow or glow.

**2. The look's parts are styled through their hook classes, from the wrapper.**
Every component carries a stable class: `.ui-h1 .ui-h2 .ui-h3 .ui-card
.ui-rowcard .ui-btn .ui-blob .ui-empty .ui-stat .ui-eyebrow
.ui-grid .ui-input .ui-field .ui-badge .ui-tabs .ui-dialog`, and the
rest of the package's `ui-*` names. Write the skin as `[data-reskin] .ui-card
{ … }`. The components themselves take no `className` and no `style`: they keep
their props (`tone`, `size`, `variant`), and the skin reaches them by class.
Every rule in the skin names a hook class or a class the app drew itself, so a
plain element the app styles with its own classes (a round floating add button
on `h-14 w-14 rounded-full`) keeps the shape those classes give it.

**Portaled parts stay in the skin.** `Dialog`, `Select`, `Popover`, `Tooltip`
and `AlertDialog` render their open content under `<body>`, outside the
wrapper. So the token block is declared on `[data-reskin], body:has([data-reskin])`,
and a rule for a portaled part is written `body:has([data-reskin]) .ui-dialog
{ … }`. `body` sits below `:root`, so its tokens win for the whole page, the
open modal and dropdown included.

**3. The skin is one module-level CSS string.** Declare `const SKIN = \`…\``
above the component and render `<style>{SKIN}</style>` as the wrapper's first
child. A later reskin rewrites this same string, so the app wears one skin
at a time. A design the person brings replaces this string whole — a pasted
palette, fonts or tokens, "use this design for the whole app": the new string
is drawn from their design alone, and the earlier skin's stripes, borders, hard
shadows, glow and the plain elements it added (a title bar, a menu strip) leave
with its colours, back only where their design asks for them, while every
component, control and record stays. Those plain elements live in the JSX,
so the build takes them out of the JSX as well as out of the string.
An action the old chrome carried stays as a plain control of their design —
a menu bar's items become `Button`s, `Tabs` or a `Select` beside the heading —
while the bar, the window frame and the title bar themselves go, the title's
words becoming the `Heading`. A change to one colour or one face of the
skin is an edit to that value in this string, and the skin keeps its shapes and
chrome: "make the accent green" moves the accent token, and the title bar stays.
Web fonts load from Google Fonts with an `@import` at the top of that
string. A heading face reads the Font card's pick first,
`font-family: var(--font-pick, 'Silkscreen', monospace)`, so the skin's face is
the default and a font the person picks in the Look tab reaches every heading
too. Plain elements the skin adds — a title bar, a menu strip, a masthead
rule, a marquee — are ordinary `div`s and `span`s that take classes freely,
styled in the same string.

**4. Motion is capture-safe.** The platform screenshots the first frame, so a
skin never starts empty: a marquee repeats its text twice in one track and
animates to `translateX(-50%)`, so the frame is full at every moment; a fade
or a flicker starts from its visible state.

**5. Layout is recomposed with the layout primitives.** Move things with
`Stack`, `Row` and `Grid` and their props, or with a plain wrapping `div`: a
centred narrow column, a two-pane window, a masthead over a three-column grid.

**An instrument keeps its face.** When the app has a `data-instrument` panel, or
is a first build whose skill teaches one
(a drum machine, a synth, a groovebox), the panel stays its own
`data-instrument` section with its own sheet, and the skin restyles it through
its picks: pad shape, panel material, LED colour role, transport layout,
beat-group colours, font. The face's colours stay `color-mix`es of the look's
tokens, and the skin adds no instrument-only colour token to the wrapper: the
face reads the shared look tokens that step 1 re-scopes, so the Look tab and
the look picker still repaint the machine after the skin lands.

The Look tab keeps working: the owner's palette picks still land on the tokens
the skin did not set, and every component, prop and record is untouched, so a
later build changes the app the ordinary way.

## A 90s Mac reading list

**Asked as:** "make it look like a 90s Mac app". Platinum grey desktop, white
windows with a 1px black border and a striped title bar, square corners, no
cushions, Chicago-like bitmap type (`Silkscreen`) over a plain grotesk body
(`Space Grotesk`), black-on-white buttons that invert when pressed.

### `App.jsx`
```jsx
import React, { useState } from "react";
import { useFireproof } from "use-fireproof";
import { useVibe } from "use-vibes";
import { Button, Card, Empty, Field, Heading, Input, Row, RowCard, Skeleton, Stack, Text } from "@vibes.diy/ui";

const SKIN = `
@import url('https://fonts.googleapis.com/css2?family=Silkscreen&family=Space+Grotesk:wght@400;600&display=swap');
[data-reskin], body:has([data-reskin]) {
  --bg: #c0c0c0; --surface: #ffffff; --ink: #000000; --text-secondary: #555555;
  --purple: #000000; --on-accent: #ffffff;
  --r-card: 0px; --r-control: 0px; --r-pill: 0px; --lip: 0px; --lip-row: 0px;
  --font-family: 'Space Grotesk', system-ui, sans-serif;
  --ui-card: none; --ui-row: none; --ui-row-hover: none; --ui-control: none; --ui-control-active: none; --ui-blob: none;
  --ui-field: inset 0 0 0 1px #000000; --ui-field-focus: inset 0 0 0 2px #000000;
  min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--font-family);
}
[data-reskin] .menubar { background: #ffffff; border-bottom: 1px solid #000000; padding: 2px 12px; font-family: 'Silkscreen', monospace; }
[data-reskin] .window { max-width: 36rem; margin: 32px auto; border: 1px solid #000000; background: #ffffff; box-shadow: 2px 2px 0 #000000; }
[data-reskin] .titlebar { height: 20px; border-bottom: 1px solid #000000; text-align: center; font-family: 'Silkscreen', monospace; font-size: 12px; line-height: 20px;
  background: repeating-linear-gradient(#ffffff 0 1px, #000000 1px 2px); }
[data-reskin] .titlebar span { background: #ffffff; padding: 0 8px; }
[data-reskin] .ui-h1, [data-reskin] .ui-h2 { font-family: var(--font-pick, 'Silkscreen', monospace); letter-spacing: 0; }
[data-reskin] .ui-card, [data-reskin] .ui-rowcard { border: 1px solid #000000; }
[data-reskin] .ui-btn { border: 1px solid #000000; background: #ffffff; color: #000000; border-radius: 6px; }
[data-reskin] .ui-btn:active { background: #000000; color: #ffffff; }
[data-reskin] .ui-empty { border: 1px dashed #000000; }
body:has([data-reskin]) .ui-dialog { border: 1px solid #000000; border-radius: 0; box-shadow: 2px 2px 0 #000000; }
`;

export default function App() {
  const { database, useLiveQuery } = useFireproof("shelf");
  const { docs } = useLiveQuery("type", { key: "book" });
  const { can, me } = useVibe("shelf");
  const [title, setTitle] = useState("");
  const canAdd = can.create({ type: "book", authorHandle: me?.userHandle });

  async function addBook(e) {
    e.preventDefault();
    const text = title.trim();
    if (text === "") return;
    setTitle("");
    await database.put({ type: "book", title: text, createdAt: Date.now(), authorHandle: me?.userHandle });
  }

  return (
    <div data-reskin>
      <style>{SKIN}</style>
      <div className="menubar">File Edit View Special</div>
      <div className="window">
        <div className="titlebar">
          <span>Reading List</span>
        </div>
        <Stack gap={4}>
          <Heading level={1}>On the shelf</Heading>
          {canAdd.pending ? (
            <div aria-busy="true">
              <Skeleton variant="card" />
            </div>
          ) : canAdd.ok ? (
            <Card>
              <form onSubmit={addBook}>
                <Stack gap={3}>
                  <Field label="Title">
                    {(id, describedBy) => <Input id={id} describedBy={describedBy} value={title} onChange={setTitle} />}
                  </Field>
                  <Row justify="end">
                    <Button type="submit">Add book</Button>
                  </Row>
                </Stack>
              </form>
            </Card>
          ) : (
            <Text muted>Adding books opens up once you're added to this shelf.</Text>
          )}
          {docs.length === 0 ? (
            <Empty title="No books yet">Add the first one above.</Empty>
          ) : (
            <Stack gap={2}>
              {docs.map((book) => (
                <RowCard key={book._id}>
                  <Text>{book.title}</Text>
                </RowCard>
              ))}
            </Stack>
          )}
        </Stack>
      </div>
    </div>
  );
}
```

## A marquee that photographs

**Asked as:** "chopped and screwed", "make it feel like a club flyer". The track
holds the line twice and moves half its width, so the first frame is already
full.

```jsx
const SKIN = `
[data-reskin] .marquee { overflow: hidden; white-space: nowrap; border-block: 2px solid var(--ink); }
[data-reskin] .marquee-track { display: inline-block; animation: slide 18s linear infinite; }
@keyframes slide { from { transform: translateX(0); } to { transform: translateX(-50%); } }
`;

function Marquee({ text }) {
  return (
    <div className="marquee" aria-label={text}>
      <span className="marquee-track" aria-hidden="true">
        {text} · {text} ·{" "}
      </span>
    </div>
  );
}

export default function App() {
  return (
    <div data-reskin>
      <style>{SKIN}</style>
      <Marquee text="Now playing, slowed down" />
    </div>
  );
}
```

## A dark mode switch

**Asked as:** "add a dark mode", "a light and dark switch", "make it dark".
The look already paints its own dark palette when the device is set to dark;
a switch puts that choice in the person's hands.

A dark mode is a second arm of the skin: the wrapper carries
`data-scheme={scheme}`, and the dark values go on the look's own token names
on `[data-reskin][data-scheme="dark"], body:has([data-reskin][data-scheme="dark"])`
— `--bg --surface --ink --text-secondary` for the components,
`--background --foreground --card --card-foreground --popover
--popover-foreground --muted-foreground` for plain elements' utilities, the
cushions `--ui-card --ui-row --ui-row-hover --ui-field --ui-field-focus`
re-drawn for a dark page, and `color-scheme: dark`. The accents keep their
colour, as the look's own dark mode does. On a light device the light side is
the look itself, so the Look tab keeps painting it; on a dark device Light
needs its own arm, the same names with light values inside
`@media (prefers-color-scheme: dark)`, so each choice shows on every device.
The switch is a `Segmented` (Light, Dark) that starts from the device's
setting. A skinned app's arms join its one `SKIN` string; an app that stays
dark is the dark arm with the wrapper set to `dark`.

```jsx
const SKIN = `
[data-reskin], body:has([data-reskin]) { min-height: 100vh; background: var(--bg); color: var(--ink); }
[data-reskin][data-scheme="dark"], body:has([data-reskin][data-scheme="dark"]) {
  color-scheme: dark;
  --bg: #121216; --surface: #1c1c22; --ink: #e6e6ea; --text-secondary: #a4a4ae;
  --background: #121216; --foreground: #e6e6ea; --card: #1c1c22; --card-foreground: #e6e6ea;
  --popover: #1c1c22; --popover-foreground: #e6e6ea; --muted-foreground: #a4a4ae;
  --ui-card: inset 0 calc(-1 * var(--lip)) 0 color-mix(in srgb, var(--purple) 16%, transparent), inset 0 6px 0 rgba(255,255,255,.07), 0 20px 40px rgba(0,0,0,.38);
  --ui-row: inset 0 calc(-1 * var(--lip-row)) 0 color-mix(in srgb, var(--purple) 14%, transparent), inset 0 4px 0 rgba(255,255,255,.06), 0 8px 18px rgba(0,0,0,.3);
  --ui-row-hover: inset 0 calc(-1 * var(--lip-row)) 0 color-mix(in srgb, var(--purple) 22%, transparent), inset 0 4px 0 rgba(255,255,255,.09), 0 12px 24px rgba(0,0,0,.38);
  --ui-field: inset 0 -4px 0 rgba(0,0,0,.25), inset 0 0 0 2px color-mix(in srgb, var(--purple) 22%, transparent);
  --ui-field-focus: inset 0 -4px 0 rgba(0,0,0,.25), inset 0 0 0 3px var(--purple);
}
@media (prefers-color-scheme: dark) {
  [data-reskin][data-scheme="light"], body:has([data-reskin][data-scheme="light"]) {
    color-scheme: light;
    --bg: #fffff0; --surface: #ffffff; --ink: #111111; --text-secondary: #555555;
    --background: #fffff0; --foreground: #111111; --card: #ffffff; --card-foreground: #111111;
    --popover: #ffffff; --popover-foreground: #111111; --muted-foreground: #555555;
    --ui-card: inset 0 calc(-1 * var(--lip)) 0 color-mix(in srgb, var(--purple) 35%, transparent), inset 0 6px 0 rgba(255,255,255,.9), 0 20px 40px rgba(0,0,0,.08);
    --ui-row: inset 0 calc(-1 * var(--lip-row)) 0 color-mix(in srgb, var(--purple) 30%, transparent), inset 0 4px 0 rgba(255,255,255,.9), 0 8px 18px rgba(0,0,0,.06);
    --ui-row-hover: inset 0 calc(-1 * var(--lip-row)) 0 color-mix(in srgb, var(--purple) 45%, transparent), inset 0 4px 0 rgba(255,255,255,.95), 0 12px 24px rgba(0,0,0,.1);
    --ui-field: inset 0 -4px 0 rgba(0,0,0,.06), inset 0 4px 0 rgba(255,255,255,.7), inset 0 0 0 2px color-mix(in srgb, var(--purple) 20%, transparent);
    --ui-field-focus: inset 0 -4px 0 rgba(0,0,0,.06), inset 0 4px 0 rgba(255,255,255,.7), inset 0 0 0 3px var(--purple);
  }
}
`;
const [scheme, setScheme] = useState(() => (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"));
// <div data-reskin data-scheme={scheme}><style>{SKIN}</style> … <Segmented label="Appearance" value={scheme}
//   onChange={setScheme} options={[{ value: "light", label: "Light" }, { value: "dark", label: "Dark" }]} /> … </div>
```

## Keepsake

A thing people print, share or hand out (a ticket, an invitation, a menu, a poster, a
certificate) is the `keepsake` skill.

## Board surface

A game board, a puzzle or a card table is the same split: the board is plain
elements the skin draws, the look's components frame it (score, buttons, the
win dialog). The board-games skill carries the worked example.

## Reading a named style

Name the five things a stranger would recognise and set each one:

- **Ground and surfaces:** `--bg`, `--surface`, `--ink`, `--text-secondary`.
- **Type:** one display face for `.ui-h1`/`.ui-h2`/`.ui-eyebrow`, read through
  `var(--font-pick, <the face>)`, one body face on `--font-family`, the
  heading scale and tracking.
- **Edges:** corners (`--r-card`, `--r-control`, `--r-pill`), borders on the
  hook classes, and the composite surfaces (`none` for flat, a hard offset for
  a print or brutalist feel).
- **Texture and chrome:** the plain elements the style is known for — a title
  bar, a masthead rule, scanlines, a grain — drawn by the wrapper's own
  elements and the CSS string.
- **Motion:** at most one signature movement, capture-safe.

A newspaper is a cream ground, black ink, a serif masthead over a rule, column
grids and no shadows; a terminal is black, one phosphor green, a mono face and
a blinking cursor that starts lit; Y2K is chrome gradients, pill corners and a
glossy highlight on `.ui-btn`. The words on screen stay the app's own: the
style is borrowed, the names and logos of whoever made it famous are not.
