Getting started
How to install dede, build a first page and give it your own look.
dede is one npm package, @dede-style/ui. It holds the React components, the layout pieces they sit in, and the tokens they use. The examples use Next.js, but any project running React 19 works the same way.
Install
Run this in your project’s folder. dede doesn’t install React: your project needs React 19 already.
npm install @dede-style/uiAdd the styles and set the mode
Import the stylesheet once, in the file that wraps every page. In Next.js that file is app/layout.tsx. In other projects it’s your entry file, such as main.tsx.
// app/layout.tsx
import "@dede-style/ui/styles.css"
import type { ReactNode } from "react"
export default function RootLayout({
children,
}: {
children: ReactNode
}) {
return (
<html lang="en" data-mode="light">
<body>{children}</body>
</html>
)
}dede has a light mode and a dark mode. Without data-mode, the page uses the mode of your base color: light for dede’s own grey, and dark if you choose a dark color (see Set your own color). To choose the mode yourself, set data-mode="light" or data-mode="dark" on <html>, as above. In projects other than Next.js, the attribute goes in index.html.
To switch mode while the app runs, change the attribute. You can also put it on any element, to switch only that part of the page.
styles.css is the whole stylesheet: a reset, the tokens, styles for plain HTML elements, layout and every component. It is the only stylesheet dede exports.
The reset clears the browser’s own styles, as Tailwind’s does: no margins, padding, borders or list bullets. dede then styles headings, paragraphs, links and plain lists again. Anything else you add starts blank. A <button> or <table> of your own has no padding or border until you give it one.
Build a page
A page is a list of Sections. Each Section holds the same four pieces, one inside the other. Section is a full-width band. Stack divides it into lanes. Slot is one region in a lane. Sleeve spaces out the content inside it: here, a heading, a line of text and a button.
Hello, dede
A heading, a line of text and an action.
<Section>
<Stack
lanes={{ base: 1, md: "1|1" }}
>
<Slot>
<Sleeve>
<h2>Hello, dede</h2>
<p>A heading, a line of text and an action.</p>
<Button
variant="primary"
>
Get started
</Button>
</Sleeve>
</Slot>
</Stack>
</Section>lanes={{ base: 1, md: "1|1" }} means one lane, then two equal lanes from md up. The keys are breakpoints, smallest first. base applies from zero width. sm (640px), md (768px), lg (1024px), xl (1280px) and 2xl (1536px) each take over from their width. These widths are measured on the Section, not the browser window, so the layout responds to the space it actually has. More on Breakpoints, and the whole chain under Layout.
Add a component
Import components from the package root, or each one from its own path, as here. Put a form control inside a Field, which gives it a label, a hint and an error message:
"use client"
import { useState } from "react"
import { Field } from "@dede-style/ui/field"
import { TextInput } from "@dede-style/ui/text-input"
export function EmailField() {
const [email, setEmail] = useState("")
return (
<Field label="Email" hint="We only use it to reply.">
<TextInput
type="email"
value={email}
onChange={setEmail}
/>
</Field>
)
}Every component page has a Properties tab. Change the props there, then copy the code for what you see. Start with Button.
Make it yours
There are three ways to change how dede looks. They differ in how far the change reaches.
Tokens: across the whole site
Tokens are the defaults every component uses. dede sets them, and you can override them. Set a token once, and everything that uses it changes, across the whole site. Here, every Card gets 12px corners.
/* your own stylesheet */
:root { --card-radius: 12px; }Props: one component, from dede’s options
A prop styles one component, but only from the options dede offers. variant="strong" picks one of dede’s looks for this badge. A prop can’t take any value you like.
<Badge variant="strong" tone="success">Live</Badge>Your own CSS: anything, on the elements you choose
Your own CSS can override anything, whether a prop picked it or a token set it, but only on the things you put your class on. dede doesn’t check it, for contrast or anything else.
/* your own stylesheet */
.badge-new { background-color: #6b21a8; color: #ffffff; }
<Badge className="badge-new">New</Badge>Your class beats dede’s CSS, wherever you import it and however simple its selector. That includes hover, pressed and disabled.
You can also set a token on your own class instead of :root. The change then applies only inside that element, such as one section of the page.
Why your CSS wins
dede puts all its CSS in a cascade layer named dede. CSS outside any layer beats CSS inside one, so your stylesheet beats dede’s without any extra work.
That also applies to rules for a whole element. A rule such as button { background: none } would remove the fill from every dede Button. If you have your own reset, or other rules for plain elements, put them in a layer that comes before dede’s.
The browser takes the order of the layers from the first @layer line it reads. So put that line in a file of its own, and import it before any other CSS. Don’t put it in the same file as an @import of dede’s stylesheet. Next.js moves imported CSS above the rest of the file, so the line would arrive too late.
Put your reset inside @layer reset { … } in its own file. Don’t add layer(reset) to the import instead. Next.js ignores a file imported that way when it builds with webpack.
/* app/layers.css: the order of the layers, on its own */
@layer reset, dede;
/* app/reset.css: your reset, inside the reset layer */
@layer reset {
/* your rules */
}
// app/layout.tsx: layers.css first, then the rest in any order
import "./layers.css"
import "@dede-style/ui/styles.css"
import "./reset.css"Only layers.css has to come first. After it, the imports can come in any order, because the layers decide which rule wins. Your reset is imported last here, and dede still beats it.
If you use Tailwind, one file is enough, because Tailwind’s own tool handles the imports. In the order line, put dede between Tailwind’s reset (base) and its classes (components and utilities). dede’s styles then beat Tailwind’s reset, and Tailwind’s classes beat dede’s, so <Button className="mt-4"> works.
/* app/globals.css. In app/layout.tsx, import this file
and remove the import of @dede-style/ui/styles.css.
dede beats Tailwind's reset; Tailwind's classes beat dede. */
@layer theme, base, dede, components, utilities;
@import "tailwindcss";
@import "@dede-style/ui/styles.css";Which to use
Start with a prop: if dede already offers the look, use it. Use a token when the change should apply everywhere. Use your own CSS for a one-off that dede doesn’t offer.
Overriding tokens
Write your overrides in your own stylesheet. Don’t edit dede’s files: an update would replace them. Override the roles (--color-surface, --color-text-primary and the rest), not the ramp underneath them. The roles are the part dede keeps stable.
Tokens other than colors are the same in light and dark mode, so one rule on :root sets them. For colors, see the next section.
Set your own color
dede’s base colors all come from one color: the color of the page. dede’s own is a light grey, #fafafa. Give dede your color, and it makes the base colors from it: cards, wells, text, icons and borders, and a dark mode to match. It also checks that text on each surface is easy to read.
1. Write your color
Add --color-base to one of your CSS files, as a hex color (#rgb or #rrggbb). These examples use app/theme.css, but any file works.
/* app/theme.css */
:root { --color-base: #eaf4ec; }2. Name that file in package.json
Add two scripts to package.json that name your CSS file. They run the dede-color command, which comes with the package, each time you start the dev server or build the site. The command reads --color-base from your file and writes dede-color.css in the same folder.
// package.json
"scripts": {
"predev": "dede-color app/theme.css",
"prebuild": "dede-color app/theme.css",
…
}3. Import the file
Import dede-color.css in your layout, after dede’s stylesheet. Add it to .gitignore too: the command makes it again on every build, so it doesn’t belong in your repository.
// app/layout.tsx
import "@dede-style/ui/styles.css"
import "./theme.css"
import "./dede-color.css"
# .gitignore
app/dede-color.cssWhat to know
Choose a light color or a dark one. Either leaves room for three levels of text: primary, secondary and tertiary. A mid color, about halfway between black and white, leaves room for one level at most. The command still writes the file, and prints a warning that says which levels fall short. Base color explains why, and lets you try a color first.
If you change the color while the dev server is running, restart the dev server to see it.
Start the dev server with npm run dev. If you run next dev directly, the command doesn’t run, so the file isn’t made or updated. If the file doesn’t exist yet, the page shows an error. That is deliberate: without the error, you would see dede’s grey and not know why.
If the color isn’t a hex value, the command stops with an error, and so does the build. If the file has no --color-base, dede keeps its own grey and the command says so.
Or set one color yourself
To change one color and leave the rest, set its role in your own CSS. Your value wins over dede’s. dede doesn’t check it for contrast, and doesn’t change the text that sits on it. Colors change with the mode, so set the role for light mode and for dark mode. If your site has one mode and no data-mode, set it once on :root instead.
/* your own stylesheet */
[data-mode="light"] { --color-surface: #faf8f5; }
[data-mode="dark"] { --color-surface: #1c1a17; }Every role, with its value in each mode, is on Color.
Next.js notes
No configuration is needed, with Turbopack or webpack. Every component can be used in a server page. The ones that need the browser are already marked "use client".
What a server page can’t do is pass a function. A Button’s onClick is a function, and so is the onChange that every input, Select, Switch and Checkbox needs. Put those controls in a component of your own, marked "use client", as the Field above is.
For AI and design tools
The package also describes dede in two forms: one for AI agents, one for design tools. Both come from the same source as the code.
For AI agents
These files are written for an AI coding assistant, or an AI design tool that builds from a description. Give them to it before you ask for a page.
DESIGN.md: the whole system in one file, with the tokens, how layout works and the rules for building a page. It’s also in the package.
llms.txt: a list of the docs, in the format AI agents look for.
docs/: one Markdown file per component, with its props. They’re in the package, and online at addresses such as /docs/Button.md.
For design tools
Design tools can import the tokens as their own variables, so colors, spacing and type match the code. They’re in tokens/, in the standard W3C DTCG JSON format: shared values in base.tokens.json, colors and shadows in light.tokens.json and dark.tokens.json, and dede.resolver.json to join them.
A design tool with AI in it, whether built in, through a plugin or as a connected agent, can also work from DESIGN.md. It adds what JSON can’t hold: which role to use where, and why.