Design systems
A page you write with the standard elements already looks finished. Buttons, inputs, tables, dialogs and the rest are drawn by a design system, today shadcn/ui, and every example in the next lessons is a live page using it. This lesson explains the settings; the following lessons show each component with all its variants.
- The default look
- Page settings
- Theme toggle
- Tokens: change everything from one place
- Light and dark on any element
- No flash with the saved theme
- Fonts from one place
- One file for the whole project
- Mistakes are reported
- Variants and sizes
- Your own styles win
- Without a design
- Where it applies
- The component lessons
The default look
You do not turn the design on. Every page uses shadcn by default, so a plain button is already a styled button, and variant and size pick another one with a single word. The behaviour (open and close, keyboard, focus, ARIA) is generated for you in the same way, so a dialog opens and a tabs element answers the arrow keys without a line of script.
page:
title = "Default design"
padding = 16
box:
layout = row
gap = 8
button:
content = "Save"
end
button:
variant = "outline"
content = "Cancel"
end
end
endPage settings
Four settings in the page block control the design for the whole page. Write enum values in quotes.
| Setting | Values | Default |
|---|---|---|
designطراحی | "shadcn" "none" | "shadcn" |
themeپوسته | "auto" "light" "dark" | "auto" |
paletteپالت | "neutral" "zinc" "stone" "slate" "gray" "mauve" "olive" "mist" "taupe" or your own | "neutral" |
design tokensتوکن های طراحی | text such as "primary: #2563eb; radius: 1rem" | none |
auto follows the system setting of the visitor, light and dark force one. The example below is dark with the zinc palette.
page:
title = "Settings"
design = "shadcn"
theme = "dark"
palette = "zinc"
padding = 16
gap = 12
box:
layout = row
gap = 8
button:
content = "Primary"
end
button:
variant = "secondary"
content = "Secondary"
end
badge:
content = "zinc, dark"
end
end
input:
placeholder = "Email"
end
endTheme toggle
The theme toggle element is a button with a sun and a moon that flips light and dark and remembers the choice of the visitor in the browser. It is a button, so it takes variant and size as well.
page:
title = "Theme"
padding = 16
box:
layout = row
gap = 8
theme toggle:
end
button:
variant = "ghost"
content = "Follows the theme"
end
end
endTokens: change everything from one place
The whole look is a set of named values, the shadcn variables: background, foreground, card, popover, primary, secondary, muted, accent, destructive, border, input, ring, radius, chart-1 to chart-5 and the sidebar group, plus font-sans and font-mono. Components never use a fixed colour; they read these values, so changing one token restyles every component that uses it.
List the ones you want to change in design tokens, separated by semicolons. A bare name sets both themes; light name and dark name set one side only. Fonts go through the same place: font-sans: "Inter", sans-serif.
page:
title = "Tokens"
padding = 16
design tokens = "primary: #2563eb; dark primary: #60a5fa; radius: 1rem"
box:
layout = row
gap = 8
button:
content = "Blue"
end
button:
variant = "outline"
content = "Outline"
end
badge:
content = "Round"
end
end
endLight and dark on any element
theme works on every element, not only on the page. A box, a card or any other element with theme = "dark" gets the dark colours for itself and everything inside it, even on a light page.
page:
title = "Scope"
theme = "light"
padding = 16
card:
padding = 16
paragraph:
content = "This card follows the page: light."
end
box:
theme = "dark"
padding = 16
radius = 8
gap = 8
paragraph:
content = "This box is dark, and so is everything inside it."
end
button:
content = "Dark button"
end
end
end
endNo flash with the saved theme
With theme = "auto" a page that has a theme toggle also reads the saved choice (the browser key salam-theme) in the head, before anything is drawn, so a visitor who picked dark never sees a light page first. Pages without a toggle get no script.
Fonts from one place
Set the families with font-sans and font-mono, then say where the files come from. font-url is a stylesheet address such as a Google Fonts link; font-face lists your own files as Family url weight, separated by commas (write + for a space in the family, add italic for an italic file). The page gets the link and @font-face rules for you.
design tokens = "font-sans: Inter, sans-serif; font-face: Inter /fonts/inter.woff2 400 700"
Inside design tokens a semicolon ends a token and an ampersand cannot be used, so write %3B and %26 in a URL there, or put the font settings in the project file below.
One file for the whole project
Put the defaults in design.toml next to your project, or in a [design] table of salam.toml. The compiler looks in the folder you build from and in the folders above it. Whatever the page sets itself wins over the file.
[design]
palette = "brand"
theme = "auto"
font-sans = "Inter, sans-serif"
font-url = "https://fonts.googleapis.com/css2?family=Inter:wght@400;700"
[design.tokens]
radius = "0.5rem"
dark-ring = "oklch(0.7 0.15 260)"
[design.palette.brand]
base = "zinc"
primary = "oklch(0.6 0.2 260)"
dark-primary = "oklch(0.7 0.15 260)"
In design.toml the same keys are written without the design. prefix ([tokens], [palette.brand]). A [design.palette.NAME] table is your own palette: base is the built in palette it starts from, and every other key is a token, with dark- or light- in front for one side only. Then palette = "brand" in the file or on a page uses it.
Mistakes are reported
A token name that does not exist (primry) or a palette that is not defined is not silently ignored: the page carries a salam-design-warning meta tag and prints the same message to the browser console. To set your own CSS variable, start the name with two dashes, as in --brand-x: #123.
Variants and sizes
A component with several looks has a variant attribute, and one with several sizes has a size attribute. Each takes a single word, and the list of words is in the lesson of the component.
Your own styles win
Every rule of the design has the lowest possible weight, so anything you write on an element, such as background = red or padding = 4, overrides it without a fight. You never need to undo the design first.
Without a design
Set design = "none" and the components lose their styling but keep their behaviour: the tabs below still switch, a dialog still opens, a menu still closes on Escape. This is also how you start your own look from nothing.
page:
title = "No design"
design = "none"
padding = 16
tabs:
default value = "a"
tab list:
tab trigger:
value = "a"
content = "One"
end
tab trigger:
value = "b"
content = "Two"
end
end
tab content:
value = "a"
paragraph:
content = "Works without a design"
end
end
tab content:
value = "b"
paragraph:
content = "Second panel"
end
end
end
endWhere it applies
The design is drawn on the web build today. The native, Android and iOS builds ignore it and keep their own drawing. More design systems will be added behind the same design setting, and each component page in the next lessons will say which ones it supports.
A new design is a new name in the design list plus its own styles, one set per component (the files ds_<design>_*.salam in layoutgen). The markup, the keyboard handling and the events stay the same, only the styles change. A component that the chosen design does not style yet falls back to the shadcn version, so a page never loses a component when you switch designs.
The component lessons
- Form components: button, input, checkbox, switch, select and the rest.
- Display components: card, badge, alert, table, avatar and more.
- Overlays and navigation: tabs, dialog, menus, tooltip.
- More components: toast, command, calendar, carousel, sidebar and charts.