# Cozy UI — full reference Cozy UI is an open-source (MIT) set of 42 chunky, toy-like React components for shadcn/ui and game UI: buttons you can press, a built-in game kit (inventory with drag and drop, character sheet, collectible cards, world map and minimap, shop and wallet, perks, skill tree), five palettes, Liquid Glass, springy motion and a full data table. Built on Radix UI and Tailwind CSS v4, installed with the shadcn CLI. Registry: https://cozy-ui.solo.engineer/r/{name}.json (namespace @cozy). License: MIT. ## Installation ### npm package (React 18 or 19, no Tailwind needed) 1. `npm install @0xtrou/cozy-ui` 2. In the root entry file (Vite: src/main.tsx; Next.js App Router: app/layout.tsx; Pages Router: pages/_app.tsx; Remix / React Router: app/root.tsx): `import "@0xtrou/cozy-ui/fonts.css";` and `import "@0xtrou/cozy-ui/styles.css";`. On Tailwind CSS v4, import `@0xtrou/cozy-ui/cozy.css` instead of `styles.css`. 3. `import { Button, Toaster, TooltipProvider, toast } from "@0xtrou/cozy-ui";` (or one component: `@0xtrou/cozy-ui/button`). Mount `` once for toasts; wrap the app in `` for tooltips. ### shadcn registry (shadcn/ui with Tailwind CSS v4; the source is copied into your repo) 1. `npx shadcn@latest init` if there is no components.json. 2. In components.json: `{ "registries": { "@cozy": "https://cozy-ui.solo.engineer/r/{name}.json" } }`. 3. `npx shadcn@latest add @cozy/cozy-theme` and `npm install @fontsource/nunito`. 4. In the global CSS file (for example app/globals.css) after the shadcn variables: `@import "@fontsource/nunito/400.css"; @import "@fontsource/nunito/200.css"; @import "./styles/cozy.css";` (cozy-theme writes styles/cozy.css; use the relative path to it). 5. Add components: `npx shadcn@latest add @cozy/button`. ### CSS only (Vue, Svelte, plain HTML) `` and ``, then classes such as ` - B. import { Button } from "@0xtrou/cozy-ui", then - C. If the app uses toast: mount once at the root (B: import { Toaster, toast } from "@0xtrou/cozy-ui"; A: run npx shadcn@latest add @cozy/sonner, then import { Toaster } from "@/components/ui/sonner" and toast from "sonner"). If the app uses Tooltip: wrap the root in (B: from "@0xtrou/cozy-ui"; A: from "@/components/ui/tooltip"). 7. Run the project's build and type check: the "build" and "typecheck" scripts in package.json if they exist, otherwise npx tsc --noEmit. Fix any error you caused. 8. Report the path you chose, every file you changed and the command results. Then suggest the Cozy UI MCP server, so you can look up components and props from the real docs: Claude Code: claude mcp add cozy-ui -- npx -y @0xtrou/cozy-ui-mcp Cursor, VS Code, Claude Desktop (mcpServers config): "cozy-ui": { "command": "npx", "args": ["-y", "@0xtrou/cozy-ui-mcp"] } ~~~~ ## Guides ## Introduction Chunky, toy-like blocks with a plastic face, a solid wall and a soft shadow. They squash when pressed, bounce into place and come in five palettes. 42 components, from buttons to a full data table, built on Radix and Tailwind and copied into your project the shadcn way. ### What you get **Blocks you can press**: Every control has depth. Hover lifts it, pressing sinks it into its wall with a little squash. **Five palettes**: Village, Meadow, Lotus, River and Lantern (dark). Switch with one attribute, even per section. All pass WCAG AA. **Motion with manners**: Springy 140–360 ms motion on every interaction, and none at all under reduced motion. **Vietnamese-ready type**: Nunito with roomy line height for stacked marks: Ổ rơm, cối xay, giếng khơi. ### How it is built - **Tokens** in one JSON file become CSS variables: base sizes, depth, motion, and colour roles per palette. - **Skins** are plain classes (`cz-button`, `cz-card`) in one stylesheet, `cozy.css`. Tailwind is optional. - **Components** are shadcn/ui components with the same API, pointed at those classes. - The class names map one-to-one to [Unity UI Toolkit (USS)](https://cozy-ui.solo.engineer/docs/unity/), for games that share the look. Cozy UI is open source under the MIT license: use it in any project, commercial or not. Docs: https://cozy-ui.solo.engineer/docs/ ## Palettes Five palettes share one set of colour roles, so every component works in all of them. Set one on the page, or on any element to theme just that part. ```html
…
``` With no `data-palette`, the page uses Village, and switches to Lantern when the system is in dark mode (or `data-theme="dark"` is set). ### Village Default. Terracotta tiles, warm lime-washed walls, rice gold and bamboo green. ### Meadow Young rice and banana leaves after rain. ### Lotus Lotus pond in early summer: petal pink, leaf green, warm cream. ### River Morning river and sky: clear blues with sandy banks. ### Lantern · dark Dark. An evening lit by an oil lamp: deep indigo, warm amber. ### Make your own Add a block to `tokens.json` under `palettes` and run `pnpm tokens`, or write the variables by hand. Every role must be set; walls are the face colour about one step darker. `pnpm contrast` checks every text pair against WCAG AA (4.5:1). my-palette.css: ```css [data-palette="tea"] { color-scheme: light; --cz-page: #F3E7C9; --cz-page-sky: #BFE3EE; --cz-surface: #FBF4E2; --cz-surface-top: #FFFAF0; --cz-surface-bottom: #F5EAD0; --cz-surface-wall: #C9A979; --cz-surface-sunken: #E8D7AE; --cz-text: #3B2618; --cz-text-muted: #6B4E36; --cz-text-inverse: #FFF8E7; --cz-outline: #5A3A28; --cz-outline-soft: #8A5B3C; --cz-primary: #B04A2C; --cz-primary-wall: #8C3920; --cz-primary-text: #FFF8E7; --cz-secondary: #E9C77E; --cz-secondary-wall: #C9A35A; --cz-secondary-text: #3B2618; --cz-success: #4F7330; --cz-success-wall: #3A5622; --cz-success-text: #FFF8E7; --cz-success-bright: #8DB84A; --cz-reward: #E2A93A; --cz-reward-wall: #B9832A; --cz-reward-text: #3B2618; --cz-danger: #9E3A2C; --cz-danger-wall: #76281E; --cz-danger-text: #FFF8E7; --cz-info: #5D7486; --cz-info-text: #FFF8E7; --cz-accent: #BFE3EE; --cz-accent-text: #3B2618; --cz-tint-success: #EEF5DD; --cz-tint-info: #E3EBF0; --cz-tint-danger: #F7E1D8; --cz-ring: #B04A2C; --cz-overlay: rgb(59 38 24 / 0.55); --cz-contact: rgb(59 38 24 / 0.38); --cz-tooltip: #5A3A28; --cz-tooltip-text: #F3E7C9; } ``` - ## Customize it for your brand Your colours, type, material and the components your product needs, tuned and contrast-checked.: [DM @_trou3 on X](https://x.com/_trou3) ### Colour roles #### Village (`village`, light) Default. Terracotta tiles, warm lime-washed walls, rice gold and bamboo green. - `--cz-page`: #F3E7C9 - `--cz-page-sky`: #BFE3EE - `--cz-surface`: #FBF4E2 - `--cz-surface-top`: #FFFAF0 - `--cz-surface-bottom`: #F5EAD0 - `--cz-surface-wall`: #C9A979 - `--cz-surface-sunken`: #E8D7AE - `--cz-text`: #3B2618 - `--cz-text-muted`: #6B4E36 - `--cz-text-inverse`: #FFF8E7 - `--cz-outline`: #5A3A28 - `--cz-outline-soft`: #8A5B3C - `--cz-primary`: #B04A2C - `--cz-primary-wall`: #8C3920 - `--cz-primary-text`: #FFF8E7 - `--cz-secondary`: #E9C77E - `--cz-secondary-wall`: #C9A35A - `--cz-secondary-text`: #3B2618 - `--cz-success`: #4F7330 - `--cz-success-wall`: #3A5622 - `--cz-success-text`: #FFF8E7 - `--cz-success-bright`: #8DB84A - `--cz-reward`: #E2A93A - `--cz-reward-wall`: #B9832A - `--cz-reward-text`: #3B2618 - `--cz-danger`: #9E3A2C - `--cz-danger-wall`: #76281E - `--cz-danger-text`: #FFF8E7 - `--cz-info`: #5D7486 - `--cz-info-text`: #FFF8E7 - `--cz-accent`: #BFE3EE - `--cz-accent-text`: #3B2618 - `--cz-tint-success`: #EEF5DD - `--cz-tint-info`: #E3EBF0 - `--cz-tint-danger`: #F7E1D8 - `--cz-ring`: #B04A2C - `--cz-overlay`: rgb(59 38 24 / 0.55) - `--cz-contact`: rgb(59 38 24 / 0.38) - `--cz-tooltip`: #5A3A28 - `--cz-tooltip-text`: #F3E7C9 #### Meadow (`meadow`, light) Young rice and banana leaves after rain. - `--cz-page`: #E9F0D2 - `--cz-page-sky`: #CFE8D8 - `--cz-surface`: #F8FBEC - `--cz-surface-top`: #FDFFF5 - `--cz-surface-bottom`: #EDF3D8 - `--cz-surface-wall`: #A9B97A - `--cz-surface-sunken`: #D9E4B8 - `--cz-text`: #26301A - `--cz-text-muted`: #4D5A36 - `--cz-text-inverse`: #FBFFF0 - `--cz-outline`: #3B4724 - `--cz-outline-soft`: #6B7A45 - `--cz-primary`: #3F6E2A - `--cz-primary-wall`: #2D521D - `--cz-primary-text`: #FBFFF0 - `--cz-secondary`: #D6E59A - `--cz-secondary-wall`: #AFC26A - `--cz-secondary-text`: #26301A - `--cz-success`: #2F6B4F - `--cz-success-wall`: #1F4D38 - `--cz-success-text`: #F2FFF7 - `--cz-success-bright`: #6FBF8E - `--cz-reward`: #E8C547 - `--cz-reward-wall`: #BC9B2C - `--cz-reward-text`: #26301A - `--cz-danger`: #A0412E - `--cz-danger-wall`: #782D20 - `--cz-danger-text`: #FFF6EE - `--cz-info`: #4F6E7E - `--cz-info-text`: #F4FBFF - `--cz-accent`: #CFE8D8 - `--cz-accent-text`: #26301A - `--cz-tint-success`: #E2F2E6 - `--cz-tint-info`: #E1EBEF - `--cz-tint-danger`: #F6E1D9 - `--cz-ring`: #3F6E2A - `--cz-overlay`: rgb(38 48 26 / 0.55) - `--cz-contact`: rgb(38 48 26 / 0.36) - `--cz-tooltip`: #3B4724 - `--cz-tooltip-text`: #E9F0D2 #### Lotus (`lotus`, light) Lotus pond in early summer: petal pink, leaf green, warm cream. - `--cz-page`: #F8E4E4 - `--cz-page-sky`: #F3D3DA - `--cz-surface`: #FFF6F3 - `--cz-surface-top`: #FFFBF9 - `--cz-surface-bottom`: #F9E8E3 - `--cz-surface-wall`: #D9A6A9 - `--cz-surface-sunken`: #F0D2CF - `--cz-text`: #3D1F28 - `--cz-text-muted`: #6E4352 - `--cz-text-inverse`: #FFF5F7 - `--cz-outline`: #5B2E3C - `--cz-outline-soft`: #8E5A68 - `--cz-primary`: #B2456A - `--cz-primary-wall`: #8A3150 - `--cz-primary-text`: #FFF5F7 - `--cz-secondary`: #F4C3CF - `--cz-secondary-wall`: #D69AAA - `--cz-secondary-text`: #3D1F28 - `--cz-success`: #4E7A43 - `--cz-success-wall`: #385A30 - `--cz-success-text`: #F7FFF2 - `--cz-success-bright`: #8CC27A - `--cz-reward`: #EFB94B - `--cz-reward-wall`: #C28E2E - `--cz-reward-text`: #3D1F28 - `--cz-danger`: #9A2F2F - `--cz-danger-wall`: #722020 - `--cz-danger-text`: #FFF5F2 - `--cz-info`: #5E6C8A - `--cz-info-text`: #F6F8FF - `--cz-accent`: #CFE6D2 - `--cz-accent-text`: #3D1F28 - `--cz-tint-success`: #EAF4E4 - `--cz-tint-info`: #E7EAF3 - `--cz-tint-danger`: #F8DEDB - `--cz-ring`: #B2456A - `--cz-overlay`: rgb(61 31 40 / 0.55) - `--cz-contact`: rgb(61 31 40 / 0.36) - `--cz-tooltip`: #5B2E3C - `--cz-tooltip-text`: #F8E4E4 #### River (`river`, light) Morning river and sky: clear blues with sandy banks. - `--cz-page`: #E2EEF2 - `--cz-page-sky`: #BFE0EE - `--cz-surface`: #F7FBFC - `--cz-surface-top`: #FFFFFF - `--cz-surface-bottom`: #E9F2F5 - `--cz-surface-wall`: #9CB8C4 - `--cz-surface-sunken`: #D3E3EA - `--cz-text`: #1C2C36 - `--cz-text-muted`: #435866 - `--cz-text-inverse`: #F5FBFF - `--cz-outline`: #2B4150 - `--cz-outline-soft`: #5A7586 - `--cz-primary`: #2D6A92 - `--cz-primary-wall`: #1F4E6D - `--cz-primary-text`: #F5FBFF - `--cz-secondary`: #EAD9AE - `--cz-secondary-wall`: #C6B07C - `--cz-secondary-text`: #1C2C36 - `--cz-success`: #2F6B55 - `--cz-success-wall`: #204D3D - `--cz-success-text`: #F2FFFA - `--cz-success-bright`: #6CC2A0 - `--cz-reward`: #E9B54A - `--cz-reward-wall`: #BD8B2E - `--cz-reward-text`: #1C2C36 - `--cz-danger`: #A33D33 - `--cz-danger-wall`: #7A2A23 - `--cz-danger-text`: #FFF6F4 - `--cz-info`: #5A6F86 - `--cz-info-text`: #F5F9FF - `--cz-accent`: #C6E6D9 - `--cz-accent-text`: #1C2C36 - `--cz-tint-success`: #E1F2EA - `--cz-tint-info`: #E2EAF2 - `--cz-tint-danger`: #F6E0DC - `--cz-ring`: #2D6A92 - `--cz-overlay`: rgb(28 44 54 / 0.55) - `--cz-contact`: rgb(28 44 54 / 0.34) - `--cz-tooltip`: #2B4150 - `--cz-tooltip-text`: #E2EEF2 #### Lantern (`lantern`, dark) Dark. An evening lit by an oil lamp: deep indigo, warm amber. - `--cz-page`: #1B1828 - `--cz-page-sky`: #272247 - `--cz-surface`: #2C2740 - `--cz-surface-top`: #363050 - `--cz-surface-bottom`: #262236 - `--cz-surface-wall`: #151222 - `--cz-surface-sunken`: #1F1B2E - `--cz-text`: #F3E7C9 - `--cz-text-muted`: #C5B79A - `--cz-text-inverse`: #1B1828 - `--cz-outline`: #0C0A14 - `--cz-outline-soft`: #4A4266 - `--cz-primary`: #E9A23B - `--cz-primary-wall`: #A86C1E - `--cz-primary-text`: #24160A - `--cz-secondary`: #4A4266 - `--cz-secondary-wall`: #2F2946 - `--cz-secondary-text`: #F3E7C9 - `--cz-success`: #79B85A - `--cz-success-wall`: #4D7E36 - `--cz-success-text`: #14200C - `--cz-success-bright`: #9BD27A - `--cz-reward`: #F2C25A - `--cz-reward-wall`: #B48A2E - `--cz-reward-text`: #24160A - `--cz-danger`: #E07A62 - `--cz-danger-wall`: #A14A36 - `--cz-danger-text`: #24100A - `--cz-info`: #8FA6C9 - `--cz-info-text`: #141A26 - `--cz-accent`: #3D5470 - `--cz-accent-text`: #F3E7C9 - `--cz-tint-success`: #2F3B2E - `--cz-tint-info`: #2B3142 - `--cz-tint-danger`: #3E2A2E - `--cz-ring`: #F2C25A - `--cz-overlay`: rgb(8 6 14 / 0.7) - `--cz-contact`: rgb(0 0 0 / 0.5) - `--cz-tooltip`: #F3E7C9 - `--cz-tooltip-text`: #1B1828 Docs: https://cozy-ui.solo.engineer/docs/palettes/ ## Materials Two materials: soft plastic (default) and Liquid Glass. Every component has a glass version: controls become clear capsules, panels and boards become regular glass, after Apple's Liquid Glass guidance. Glass looks best over colour or a picture. It works with every palette. ### Turn it on For the whole app, or one section such as a game HUD or a hero: ```html
…
``` Inside a glass page, `data-material="plastic"` turns one area back to plastic. Glass reads best over colour or a picture. `cz-glass-backdrop` paints soft palette-coloured light; any image or scene behind works too. ### What changes | Part | Plastic | Glass | |---|---|---| | Controls | Raised blocks with a wall | Clear glass capsules: a light blur, a thin bright rim and a soft floating shadow (buttons, select, tabs, toggles, checkbox, radio, calendar days) | | Prominent actions | Coloured plastic | Tinted glass (primary, success, destructive, reward, secondary), and tinted glass badges | | Panels and boards | Plastic boards | Regular glass: stronger blur and luminosity so text reads (cards, alerts, accordions, tables, calendar, dialogs, sheets, menus, popovers, toasts) | | Fields | Sunken wells | Clear wells with a soft inner shadow (inputs, search, facets) | | Press | Sinks into its wall | Swells and brightens, like a drop | ### Readable by default - Tinted glass with light text is deepened first, dark palettes dim the glass instead of lightening it, and boards keep 72% of their colour, so every text pair passes WCAG AA in all five palettes, over the page and over the backdrop's colour pools (checked by `pnpm contrast`). - With `prefers-reduced-transparency` or `prefers-contrast: more`, glass turns solid and the blur is off. ### Tune it CSS: ```css [data-material="glass"] { --cz-glass-fill: light-dark(rgb(255 255 255 / 0.2), rgb(12 10 20 / 0.28)); --cz-glass-tint: 82%; /* colour kept on tinted (prominent) glass */ --cz-glass-board: 72%; /* surface colour kept on dialogs, menus, sheets */ --cz-glass-control-filter: blur(3px) saturate(1.8) brightness(1.06); --cz-glass-board-filter: blur(22px) saturate(1.8) brightness(1.04); } ``` Lower values make the glass clearer but can drop text contrast; run your colours through a contrast check if you change them. - ## Customize it for your brand Your colours, type, material and the components your product needs, tuned and contrast-checked.: [DM @_trou3 on X](https://x.com/_trou3) Docs: https://cozy-ui.solo.engineer/docs/materials/ ## Motion Short, springy and physical, like soft toys. Durations stay between 80 and 360 ms. Everything stops under `prefers-reduced-motion`. ### Utilities Add a class to any element. Click a tile to replay it. - `cz-motion-pop`: Rewards and toasts appearing - `cz-motion-bounce-in`: Cards dealt onto the table - `cz-motion-rise`: Content fading up into place - `cz-motion-jelly`: Something just got filled or ticked - `cz-motion-wiggle`: Nudge: “tap me” - `cz-motion-shake`: Not allowed / wrong input - `cz-motion-swing`: Hanging tags and signs - `cz-motion-float`: Idle bubbles over the world (loops) ### Built into components | Component | Motion | |---|---| | Button | Hover lifts 2 px and grows the wall; press sinks it with a 2% squash (80 ms), release springs back with overshoot. | | Checkbox | Box does a jelly wobble; the tick is stamped in, rotating from −12°. | | Switch | Thumb rolls with a bounce and squashes as it lands. | | Slider | Thumb swells on hover and flattens while dragged. | | Tabs | One raised tile slides to the active tab with overshoot; the panel rises in. | | Progress | Fill springs to its value; stripes roll; at 100% it glints. | | Tooltip | Swings in like a hanging tag. | | Dialog | Overlay fades; the board bounces in and drops away on close. | | Input | Shakes once when it becomes invalid. | ### Tokens | Token | Value | Use | |---|---|---| | `--cz-motion-instant` | `80ms` | | | `--cz-motion-fast` | `140ms` | hover, press | | `--cz-motion-base` | `220ms` | toggles, tabs, tooltips | | `--cz-motion-slow` | `360ms` | dialogs, toasts, progress | | `--cz-motion-ease-out` | `cubic-bezier(0.2, 0.8, 0.2, 1)` | | | `--cz-motion-ease-bounce` | `cubic-bezier(0.34, 1.56, 0.64, 1)` | toy-like overshoot; USS: ease-out-back | | `--cz-motion-ease-spring` | `cubic-bezier(0.5, 1.8, 0.4, 0.8)` | stronger overshoot for pops | Keyframes animate the individual `translate`, `scale` and `rotate` properties, so they never fight the `transform` that Radix and sonner use for positioning. ```css .my-coin-burst { animation: cz-pop var(--cz-motion-slow) var(--cz-motion-ease-out) both; } ``` Docs: https://cozy-ui.solo.engineer/docs/motion/ ## Tokens One JSON file, `tokens.json`, is the source. A script writes the CSS variables; the same file can feed other platforms. Colour roles are listed on [Palettes](https://cozy-ui.solo.engineer/docs/palettes/). ### Radius | Variable | Value | Note | |---|---|---| | `--cz-radius-sm` | `8px` | | | `--cz-radius-md` | `12px` | buttons, inputs | | `--cz-radius-lg` | `16px` | cards, toasts | | `--cz-radius-xl` | `22px` | dialogs | | `--cz-radius-full` | `999px` | switches, avatars, progress | ### Border | Variable | Value | Note | |---|---|---| | `--cz-border-thin` | `2px` | badges, small chips, in-game HUD | | `--cz-border-thick` | `3px` | buttons, inputs, cards | | `--cz-border-frame` | `5px` | dialog frame | ### Depth | Variable | Value | Note | |---|---|---| | `--cz-depth-lift` | `7px` | height of a raised block: its solid side wall | | `--cz-depth-lift-hover` | `9px` | | | `--cz-depth-lift-sm` | `5px` | | | `--cz-depth-press` | `1px` | what is left of the wall while pressed | ### Shadow | Variable | Value | Note | |---|---|---| | `--cz-shadow-rim` | `inset 0 3px 0 rgb(255 255 255 / 0.55)` | rim light on the top edge | | `--cz-shadow-bevel` | `inset 0 -5px 0 rgb(0 0 0 / 0.16)` | darker lower lip | | `--cz-shadow-well` | `inset 0 4px 0 rgb(0 0 0 / 0.14), inset 0 8px 10px -4px rgb(0 0 0 / 0.12)` | sunken wells: inputs, tracks | | `--cz-shadow-plastic` | `linear-gradient(180deg, rgb(255 255 255 / 0.32) 0%, rgb(255 255 255 / 0.06) 48%, rgb(0 0 0 / 0.08) 100%)` | soft plastic face overlay, layered over the face colour | | `--cz-shadow-specular` | `rgb(255 255 255 / 0.55)` | small glint, top left | ### Space | Variable | Value | Note | |---|---|---| | `--cz-space-1` | `4px` | | | `--cz-space-2` | `8px` | | | `--cz-space-3` | `12px` | | | `--cz-space-4` | `16px` | | | `--cz-space-5` | `20px` | | | `--cz-space-6` | `24px` | | | `--cz-space-8` | `32px` | | | `--cz-space-10` | `40px` | | | `--cz-space-12` | `48px` | | ### Size | Variable | Value | Note | |---|---|---| | `--cz-size-touch` | `44px` | minimum touch target | | `--cz-size-control-sm` | `36px` | | | `--cz-size-control-md` | `48px` | | | `--cz-size-control-lg` | `56px` | | ### Font | Variable | Value | Note | |---|---|---| | `--cz-font-family` | `"Nunito", ui-rounded, system-ui, sans-serif` | Nunito (SIL OFL 1.1): rounded, full Vietnamese and Latin coverage | | `--cz-font-weight-regular` | `400` | | | `--cz-font-weight-thin` | `200` | display only, 24px and up | | `--cz-font-size-xs` | `12px` | absolute minimum | | `--cz-font-size-sm` | `14px` | minimum for body copy | | `--cz-font-size-md` | `16px` | | | `--cz-font-size-lg` | `20px` | | | `--cz-font-size-xl` | `24px` | | | `--cz-font-size-2xl` | `32px` | | | `--cz-font-size-3xl` | `44px` | | | `--cz-font-line-height` | `1.45` | roomy: Vietnamese stacks two diacritics (Ổ, Ấ) | ### Motion | Variable | Value | Note | |---|---|---| | `--cz-motion-instant` | `80ms` | | | `--cz-motion-fast` | `140ms` | hover, press | | `--cz-motion-base` | `220ms` | toggles, tabs, tooltips | | `--cz-motion-slow` | `360ms` | dialogs, toasts, progress | | `--cz-motion-ease-out` | `cubic-bezier(0.2, 0.8, 0.2, 1)` | | | `--cz-motion-ease-bounce` | `cubic-bezier(0.34, 1.56, 0.64, 1)` | toy-like overshoot; USS: ease-out-back | | `--cz-motion-ease-spring` | `cubic-bezier(0.5, 1.8, 0.4, 0.8)` | stronger overshoot for pops | Docs: https://cozy-ui.solo.engineer/docs/tokens/ ## Build game UI Cozy UI ships ready-made game screens: inventory, item details, character sheet, collection book, collectible cards, a world map, a minimap, a shop with a wallet and purchase dialog, perks, a skill tree and buffs. They hold no game rules. You pass plain data, they draw it and tell you what the player did, so they fit any game state: React state, a store, a server or an ECS. ### What is in the kit | Component | What it does | Wire it with | |---|---|---| | [Inventory](https://cozy-ui.solo.engineer/docs/components/inventory/) | Bag, chest or hotbar: drag and drop with mouse, touch and keyboard, stacking and merging, locked slots, tabs, search and sort. | `items``onItemsChange(next``change)` | | [Item Info](https://cozy-ui.solo.engineer/docs/components/item-info/) | Item details and tooltips: rarity, stats, compare against what is equipped (+/- in colour), action buttons. | `item``compareTo``actions` | | [Character Info](https://cozy-ui.solo.engineer/docs/components/character-info/) | Character sheet: portrait, level and XP, health and energy bars, attributes with bonuses, status chips, equipment slots. | `character``onEquipmentSelect` | | [Gallery](https://cozy-ui.solo.engineer/docs/components/gallery/) | Collection book for items, creatures or friends: silhouettes until found, progress, filters, a big view with next and previous. | `entries``onOpenChange` | | [Item Card](https://cozy-ui.solo.engineer/docs/components/item-card/) | Collectible cards with rarity frames, elements, abilities, foil, 3D tilt and flip. CardHand fans a hand; CardGrid is a binder. | `card``onSelect``owned` | | [Currency Bar](https://cozy-ui.solo.engineer/docs/components/currency-bar/) | HUD wallet: animated amounts, floating +/- deltas, caps like 35 / 60, a get-more button and a "not enough" shake. | `wallet``onAdd``highlight` | | [Shop](https://cozy-ui.solo.engineer/docs/components/shop/) | In-game store: category tabs, featured deals with countdowns, discounts, stock, owned items and real-money currency packs. | `items``wallet``onBuy` | | [Purchase Dialog](https://cozy-ui.solo.engineer/docs/components/purchase-dialog/) | The confirm step: quantity, total, balance before and after, get more, then busy, success or error. Your game charges. | `item``wallet``onConfirm` | | [Perk Picker](https://cozy-ui.solo.engineer/docs/components/perk-picker/) | Pick one of a few perks on level-up, with rarity, reroll, skip and confirm. | `perks``onConfirm``onReroll` | | [Skill Tree](https://cozy-ui.solo.engineer/docs/components/skill-tree/) | Talent tree: prerequisites, ranks, points, learn and refund, pan and zoom, a details panel. | `nodes``ranks``onRanksChange``points` | | [Buff Bar](https://cozy-ui.solo.engineer/docs/components/buff-bar/) | Active buffs and debuffs with countdown rings, stacks and tooltips. | `buffs``onExpire` | | [Game Map and MiniMap](https://cozy-ui.solo.engineer/docs/components/game-map/) | World map like a maps app (pins, clusters, place panel, search, filter chips, waypoints, clouds over unexplored land) and a HUD minimap with edge arrows. | `markers``regions``player``onMarkerSelect` | Two full screens show them together: the [Character Screen](https://cozy-ui.solo.engineer/blocks/character-screen/) (sheet, bag, item details, equip and sell, collection) and the [Village HUD](https://cozy-ui.solo.engineer/blocks/village-hud/) (resources, harvest button, level-up cards, minimap that opens the map) and the [Village Shop](https://cozy-ui.solo.engineer/blocks/village-shop/) (wallet, shelves, purchase dialog, gem packs). ### Install With npm, everything is in one package: Terminal: ```bash npm install @0xtrou/cozy-ui ``` main.tsx: ```tsx import "@0xtrou/cozy-ui/styles.css" import { Inventory, ItemCard, GameMap, MiniMap } from "@0xtrou/cozy-ui" ``` Or copy the source into your project with the shadcn CLI and change anything: Terminal: ```bash npx shadcn@latest add @cozy/cozy-theme @cozy/inventory @cozy/item-info @cozy/character-info @cozy/gallery @cozy/item-card @cozy/game-map @cozy/currency-bar @cozy/shop @cozy/purchase-dialog @cozy/perk-picker @cozy/skill-tree @cozy/buff-bar ``` ### Data in, events out Every game component takes plain objects and calls you back. Keep the real state where your game keeps it and hand the components a view of it. Each item, card, entry and marker has a `data` field typed by you, so your own object comes back in every event. Backpack.tsx: ```tsx import { Inventory, ItemInfo, type GameItem, type InventorySlots } from "@0xtrou/cozy-ui" // Your game state: a store, a server snapshot or ECS components. const bag: InventorySlots = useGame((s) => s.bag) const [selected, setSelected] = useState(null) { // change: { type: "move" | "merge" | "sort", from, to } game.send({ type: "bag/update", next, change }) }} selected={selected} onSelect={(_, index) => setSelected(index)} onActivate={(item) => game.send({ type: "use", id: item.id })} // double-click or Enter /> {selected != null && bag[selected] && } ``` ### Cards from your items A card is one object. Art can be a React node (SVG, sprite, canvas) or an image URL; elements and rarities are your own sets. Deck.tsx: ```tsx import { ItemCard, CardHand, type CardData } from "@0xtrou/cozy-ui" const toCard = (c: MyCard): CardData => ({ id: c.id, name: c.name, art: c.imageUrl, rarity: c.rarity, element: c.element, stat: { label: "HP", value: c.hp }, type: c.typeLine, abilities: c.moves.map((m) => ({ name: m.name, cost: m.cost, value: m.damage, text: m.text })), footer: { number: `${c.no}/120`, set: "Village Set" }, data: c, }) play(card.data!)} /> ``` ### Map and minimap from one world Use your game's own coordinates. Both components take the same object, so the minimap and the full map never disagree. Mark a region `discovered: false` to keep it under clouds until the player gets there. WorldMap.tsx: ```tsx import { GameMap, MiniMap, useRegionChange } from "@0xtrou/cozy-ui" const world = { mapWidth: 1200, mapHeight: 800, background: "/maps/village.png", kinds: { shop: { label: "Shops", icon: , color: "#7FC4E0" } }, markers: places.map((p) => ({ id: p.id, x: p.x, y: p.y, label: p.name, kind: p.kind, tracked: p.quest })), regions, player: { x: me.x, y: me.y, heading: me.facing }, waypoint, } useRegionChange(world.regions, world.player, (r) => r && toast(`Entering ${r.name}`)) setMapOpen(true)} /> } /> ``` ### Shop and payments Cozy UI draws the store; it never charges anyone. In-game prices use your currencies (`{ currency: "coin", amount: 120 }`); real-money prices are strings your store SDK already formatted (`{ real: "$4.99" }`). Call the App Store or Google Play in-app purchase API (required for digital goods in mobile apps) or Stripe on the web from `onConfirm`, and return its Promise: the dialog shows busy, then success or the error with a retry. Store.tsx: ```tsx import { CurrencyBar, Shop, PurchaseDialog, spend } from "@0xtrou/cozy-ui" setTab("gems")} highlight={short} />} /> !o && setPicked(null)} item={picked} wallet={wallet} maxQuantity={10} realMoneyNote="Charged by the App Store" onGetMore={(currency) => { setPicked(null); setTab("gems"); setShort(currency) }} onConfirm={(item, qty) => item.data.iap ? store.purchase(item.data.sku) // your IAP / Stripe call, returns a Promise : game.buy(item.id, qty)} // or spend(wallet, price) for in-game coins /> ``` ### Perks, skills and buffs The game keeps the rules: which perks are offered, how many points the player has, when a buff ends. The components show them and report choices. Skill points are yours to count; `spentPoints(ranks, nodes)` and `canLearn(...)` help on the server too. LevelUp.tsx: ```tsx import { PerkPicker, SkillTree, BuffBar, spentPoints } from "@0xtrou/cozy-ui" game.takePerk(perk.id)} /> game.learn(change.id, change.to)} points={level * 2 - spentPoints(ranks, tree)} level={level} allowRefund /> ({ id: e.id, name: e.name, icon: e.icon, endsAt: e.endsAt }))} onExpire={(b) => game.removeEffect(b.id)} /> ``` ### Rarities, elements and look - Rarity colours come from the palette (`--cz-rarity-common` … `--cz-rarity-legendary`). Pass `rarities` to use your own names and colours. - Card elements come from `DEFAULT_ELEMENTS`; pass `elements` with your own set. - Every `render*` prop (renderCard, renderDetail, renderArt, renderMarker, renderDetails…) swaps one part and keeps the rest. - All five [palettes](https://cozy-ui.solo.engineer/docs/palettes/) and the [glass material](https://cozy-ui.solo.engineer/docs/materials/) apply to the game components too. ### Input and accessibility - Mouse, touch and keyboard everywhere: drag items or press Space to pick up and arrow keys to move; arrow keys and +/− on the map; Enter on cards. - Changes are announced to screen readers, and every control has a name. - Tilt, foil, map glide and other motion turn off for people who ask for reduced motion. ### Game engines For web games (React, Phaser or PixiJS with a React overlay, Three.js) use the components directly over your canvas. For Unity, the same tokens and class names map to UI Toolkit: see the [Unity guide](https://cozy-ui.solo.engineer/docs/unity/). Docs: https://cozy-ui.solo.engineer/docs/game-ui/ ## MCP server Give your AI assistant the Cozy UI docs. `@0xtrou/cozy-ui-mcp` is a Model Context Protocol server with every component’s docs, install commands, tokens and palettes. It runs locally over stdio and works offline. ### Claude Code ```bash claude mcp add cozy-ui -- npx -y @0xtrou/cozy-ui-mcp ``` ### Claude Desktop, Cursor, VS Code mcp config: ```json { "mcpServers": { "cozy-ui": { "command": "npx", "args": ["-y", "@0xtrou/cozy-ui-mcp"] } } } ``` ### mcpfs [mcpfs](https://github.com/openai/mcpfs) mounts MCP servers as a read-only folder, so agents and scripts can use `ls`, `cat` and `grep` on the docs, and run tools as commands. ```bash npm install -g @0xtrou/cozy-ui-mcp mkdir -p /tmp/cozy mcpfs-fusefs mount stdio:// /tmp/cozy -- cozy-ui-mcp ls /tmp/cozy/resources/cozy-ui/components cat /tmp/cozy/resources/cozy-ui/components/sheet.md /tmp/cozy/tools/get_install_command --components '["button","sheet"]' --method npm /tmp/cozy/search 'sticky header' fusermount3 -u -- /tmp/cozy ``` ### Resources | URI | What | |---|---| | `cozy-ui://overview.md` | What Cozy UI is and every page of the docs | | `cozy-ui://install.md` | npm and shadcn CLI install steps | | `cozy-ui://palettes.md` | The five palettes and their colour roles | | `cozy-ui://tokens.json` | All design tokens | | `cozy-ui://components/.md` | One per component: description, install, usage, props, example and source | ### Tools | Tool | Input | Returns | |---|---|---| | `list_components` | `–` | Every component with a one-line description | | `get_component` | `name` | The full docs of one component | | `search_docs` | `query, limit?` | Best matches with excerpts | | `get_install_command` | `components[], method? (npm \| shadcn)` | The exact install command and import | Prefer plain text? The same content is at [llms.txt](https://cozy-ui.solo.engineer/llms.txt) and [llms-full.txt](https://cozy-ui.solo.engineer/llms-full.txt). Docs: https://cozy-ui.solo.engineer/docs/mcp/ ## Unity UI Toolkit The structure is built to port to Unity UI Toolkit (USS): the same tokens, the same class names. Here is what carries over and what needs another route. | Web | Unity (USS) | |---|---| | `CSS variables (--cz-*)` | USS variables, same names. Generate a tokens.uss from tokens.json. | | `.cz-button, .cz-button--primary` | Same USS class names on VisualElements. | | `:hover :active :focus :disabled` | USS pseudo-classes of the same name; :checked for Toggle. | | `[data-state] from Radix` | Add or remove a class from C# (e.g. .is-checked). | | `box-shadow, gradients` | Not in USS. Use 9-slice sprites (-unity-slice-*) of each block, or draw with Painter2D. | | `::before glint` | A child VisualElement. | | `color-mix(), filter` | Pre-compute the colours as extra tokens. | | `transition` | Supported. Use ease-out-back for --cz-motion-ease-bounce. | | `@keyframes` | Not in USS. Drive with experimental.animation or a small tween in C#. | | `@font-face` | Create a Font Asset from the same TTF files. | ### Example Button.uss: ```css :root { --cz-primary: #B04A2C; --cz-outline: #5A3A28; --cz-radius-md: 12px; } .cz-button { border-width: 3px; border-color: var(--cz-outline); border-radius: var(--cz-radius-md); min-height: 48px; /* face, rim, wall and contact shadow come from a 9-slice sprite */ background-image: url("project://database/Assets/UI/button-primary.png"); -unity-slice-left: 16; -unity-slice-right: 16; -unity-slice-top: 12; -unity-slice-bottom: 18; transition: translate 140ms ease-out-back; } .cz-button:hover { translate: 0 -2px; } .cz-button:active { translate: 0 6px; } ``` Tip: the 9-slice sprites can be captured from this site with a headless browser, one per variant and state, so the game and the web stay identical. Docs: https://cozy-ui.solo.engineer/docs/unity/ ## FAQ ### What is Cozy UI? Cozy UI is a free, MIT-licensed set of React components for shadcn/ui with a chunky, toy-like 3D look: each control has a plastic face, a solid side wall and a soft contact shadow, and it sinks when pressed. It ships 42 components, including game UI (inventory, character sheet, item info, gallery), five palettes, a Liquid Glass material and a motion system. ### How do I install Cozy UI? Either npm install @0xtrou/cozy-ui and import "@0xtrou/cozy-ui/styles.css", or add the registry to components.json ("@cozy": "https://cozy-ui.solo.engineer/r/{name}.json"), then run npx shadcn@latest add @cozy/cozy-theme @cozy/button. The CLI copies the source into your project; nothing is installed from npm except the usual Radix and Tailwind dependencies. ### Does it work with Next.js, Vite and Remix? Yes. Any React 18 or 19 project set up for shadcn/ui with Tailwind CSS v4 works. The styles are plain CSS classes in one file (cozy.css), so they also work without Tailwind. ### Is there a dark mode? Yes. The Lantern palette is dark and is used automatically when the system is in dark mode, unless you pin a palette with data-palette. ### Is it accessible? Components are built on Radix UI primitives with keyboard support and ARIA. Every palette's text pairs pass WCAG AA (4.5:1), touch targets are at least 44 px, and all motion stops under prefers-reduced-motion. ### Is it made for games? Yes. It has a built-in game kit: an inventory with drag and drop and stacking, item info with stat compare, a character sheet with equipment, a collection gallery, collectible cards with foil, tilt and flip, a world map with pins, clusters, search and waypoints, and a HUD minimap. They take plain data and emit events, so any game state works. See the Build game UI guide. Tokens and class names also map to Unity UI Toolkit (USS). ## Button A chunky pressable block. It lifts on hover and sinks into its own wall when pressed. Docs: https://cozy-ui.solo.engineer/docs/components/button/ Install: `npx shadcn@latest add @cozy/button` ### Usage ```tsx import { Button } from "@/components/ui/button" ``` ### Props | Prop | Type | Default | Description | |---|---|---|---| | variant | `"default" \| "secondary" \| "success" \| "reward" \| "outline" \| "ghost" \| "destructive"` | `"default"` | Face and wall colours, from the active palette. | | size | `"default" \| "sm" \| "lg" \| "icon" \| "icon-sm"` | `"default"` | Every size keeps a 44 px touch target or more. | | loading | `boolean` | `false` | Spinner, aria-busy, disabled while true. | | asChild | `boolean` | `false` | Render the child element (for example a link) with button styling. | ### Example ```tsx import { Button } from "@/components/ui/button"; export default function ButtonDemo() { return (
); } ``` ### Source (components/ui/button.tsx) ```tsx import * as React from "react"; import { Slot } from "radix-ui"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const buttonVariants = cva("cz-button", { variants: { variant: { default: "cz-button--primary", secondary: "cz-button--secondary", success: "cz-button--success", reward: "cz-button--reward", outline: "cz-button--outline", ghost: "cz-button--ghost", destructive: "cz-button--destructive", }, size: { default: "", sm: "cz-button--sm", lg: "cz-button--lg", icon: "cz-button--icon", "icon-sm": "cz-button--icon cz-button--sm", }, }, defaultVariants: { variant: "default", size: "default" }, }); type ButtonProps = React.ComponentProps<"button"> & VariantProps & { asChild?: boolean; /** Shows a spinner and blocks clicks while true. */ loading?: boolean; }; function Button({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }: ButtonProps) { const Comp = asChild ? Slot.Root : "button"; return ( {asChild ? children : ( <> {loading && } {children} )} ); } export { Button, buttonVariants }; ``` ## Input A text field carved into the surface: the opposite of a button, it sinks in. Docs: https://cozy-ui.solo.engineer/docs/components/input/ Install: `npx shadcn@latest add @cozy/input` ### Usage ```tsx import { Input } from "@/components/ui/input" ``` Set aria-invalid="true" for errors and always pair it with text; colour alone is never the only signal. ### Example ```tsx import { Input } from "@/components/ui/input"; export default function InputDemo() { return ; } ``` ### Source (components/ui/input.tsx) ```tsx import * as React from "react"; import { cn } from "@/lib/utils"; function Input({ className, type, ...props }: React.ComponentProps<"input">) { return ; } export { Input }; ``` ## Textarea Multi-line version of Input with the same sunken well. Docs: https://cozy-ui.solo.engineer/docs/components/textarea/ Install: `npx shadcn@latest add @cozy/textarea` ### Usage ```tsx import { Textarea } from "@/components/ui/textarea"