Tokens05
A token is a named design decision: "the primary color", "how thick a border is", "how a dialog arrives". Plonk's tokens are CSS variables, and a personality is just a set of values for them.
Colors
--plonk-color-canvas- #FFF9EC
- Page background behind components.
--plonk-color-surface- #FFFFFF
- Cards, fields, menus, dialogs.
--plonk-color-sunken- #FFFDF8
- Recessed areas inside a surface.
--plonk-color-ink- #1F1A17
- Text, borders and hard shadows.
--plonk-color-ink-muted- #6B625B
- Secondary text and hints.
--plonk-color-primary- #FFD23F
- Main actions and selection.
--plonk-color-on-primary- #1F1A17
- Text and icons on primary.
--plonk-color-accent- #FF8CC6
- Highlights and badges.
--plonk-color-on-accent- #1F1A17
- Text and icons on accent.
--plonk-color-secondary- #5FBFFF
- Second-tier actions.
--plonk-color-on-secondary- #1F1A17
- Text and icons on secondary.
--plonk-color-success- #7DDE92
- Done, saved, switched on.
--plonk-color-on-success- #1F1A17
- Text and icons on success.
--plonk-color-warning- #FFB547
- Needs attention.
--plonk-color-on-warning- #1F1A17
- Text and icons on warning.
--plonk-color-danger- #FF6B6B
- Destructive actions and errors.
--plonk-color-on-danger- #1F1A17
- Text and icons on danger.
--plonk-color-focus- #1E7FE0
- Keyboard focus ring and field glow.
Shape
--plonk-border-width- 2.5px
- Every outline.
--plonk-shadow-x- 4px
- Hard shadow offset, horizontal.
--plonk-shadow-y- 4px
- Hard shadow offset, vertical.
--plonk-shadow-color- var(--plonk-color-ink)
- Hard shadow color.
--plonk-radius-sm- 8px
- Small corners: checkboxes, badges.
--plonk-radius-md- 12px
- Buttons, fields, cards.
--plonk-radius-lg- 18px
- Dialogs and large panels.
--plonk-radius-pill- 999px
- Switches, tabs, pills.
--plonk-tilt- 1.5deg
- The slight angle things are stuck on at.
Type
--plonk-font-display- "Baloo 2", ui-rounded, system-ui, sans-serif
- Headings, buttons, labels.
--plonk-font-body- "Nunito", ui-rounded, system-ui, sans-serif
- Running text.
--plonk-font-mono- ui-monospace, "SF Mono", Menlo, monospace
- Code and keyboard keys.
--plonk-font-display-case- none
- uppercase for fonts that only draw capitals, so i becomes İ in Turkish.
--plonk-font-display-tracking- 0em
- Letter spacing for the display font.
Motion
--plonk-motion-press-easing- cubic-bezier(0.3, 0.7, 0.4, 1)
- Going down under the finger.
--plonk-motion-press-duration- 70ms
- Duration of press.
--plonk-motion-spring-easing- linear(…) spring
- Coming back after a press.
--plonk-motion-spring-duration- 730ms
- Duration of spring.
--plonk-motion-snap-easing- linear(…) spring
- Indicators moving to a new spot.
--plonk-motion-snap-duration- 762ms
- Duration of snap.
--plonk-motion-enter-easing- linear(…) spring
- Overlays arriving.
--plonk-motion-enter-duration- 814ms
- Duration of enter.
--plonk-motion-exit-easing- cubic-bezier(0.4, 0, 1, 1)
- Overlays leaving.
--plonk-motion-exit-duration- 140ms
- Duration of exit.
--plonk-jelly-amount- 0.75
- 0 is off, 1 is full jelly.
--plonk-jelly-duration- 620ms
- How long the wobble lasts.
What these do is covered in Motion.
Overriding tokens
Target a personality with its attribute:
[data-plonk-personality="sticker"] {
--plonk-border-width: 3px;
--plonk-radius-md: 4px;
}Or every personality at once:
[data-plonk-personality] {
--plonk-shadow-x: 6px;
--plonk-shadow-y: 6px;
}Why not :root?
Each PlonkProvider renders an element that defines all the tokens for its
personality. Variables set on :root are inherited only until that element
redefines them, so inside a provider your :root values never show up. The
attribute selector lands on the provider's element itself, so it wins.
Plonk's own values sit in the base cascade layer. Any CSS you write without
a layer comes later and beats them, no !important needed.
In TypeScript
The provider's style accepts every token by name. Your editor completes them
and a typo is a type error:
<PlonkProvider style={{ "--plonk-radius-md": "4px" }}>
<App />
</PlonkProvider>;The type is exported as PlonkStyle if you build your own wrapper.
Advanced: component hooks
A few components read extra variables for adjustments that don't fit a global token. Plonk styles its components with Tailwind classes, and Tailwind's utilities beat any regular stylesheet rule aimed at those components. These variables are the way in.
| Variable | Changes |
|---|---|
--plonk-button-radius | Button corners |
--plonk-dialog-radius | Dialog corners |
--plonk-popover-radius | Popover corners |
--plonk-tabs-radius | Tab bar and indicator corners |
--plonk-shadow-glow | An extra shadow after the hard one (Arcade's neon) |
--plonk-item-on-bg | Highlighted list item background (Menu, Select, ComboBox) |
--plonk-item-on-ink | Highlighted list item text |
--plonk-item-on-shadow | Highlighted list item shadow |
--plonk-item-on-transform | Highlighted list item transform |
--plonk-press-effect | none turns off Comic and Arcade press effects |
/* Pill-shaped buttons in Sticker */
[data-plonk-personality="sticker"] {
--plonk-button-radius: 999px;
}Hooks are less stable than tokens: they follow the components' internals and may change between minor versions.