Skip to content

Margin, a shadcn/ui preset

Periwinkle with Hanken Grotesk: Copybook’s second set. It comes from Copybook, one of our website themes.

Fonts: Hanken Grotesk · radius 0.875rem · light and dark · lowest text contrast 4.56:1

npx shadcn@latest add https://www.themes.dev/r/presets/margin.json
Edit in the generator

Margin on six free blocks from themes.dev UI. Scroll inside the preview.

The colours

The main variables, light and dark. The full set of 31 per mode, sidebar and charts included, is in the CSS below.

Light

  • background#ffffff
  • foreground#111316
  • primary#7364de
  • primary-foreground#ffffff
  • secondary#f6f2f3
  • muted-foreground#50555c
  • accent#eeecfe
  • border#e3e4e8
  • destructive#b42318
  • ring#111316
  • chart-1#b9b5ff
  • chart-2#8a7ff2
  • chart-3#6e63c8
  • chart-4#554ba3
  • chart-5#413782

Dark

  • background#0f1114
  • foreground#ecedeb
  • primary#afa9ff
  • primary-foreground#111316
  • secondary#1e2126
  • muted-foreground#b1b7be
  • accent#252446
  • border#2a2e34
  • destructive#ff9788
  • ring#8a7dfa
  • chart-1#bcb9ff
  • chart-2#968cff
  • chart-3#7970d5
  • chart-4#5d54ad
  • chart-5#48408c

Contrast, checked

Every pair shadcn/ui draws text with, measured as WCAG 2 contrast (AA needs 4.5:1) and APCA Lc (we ask 60 for text). Focus rings need 3:1 on the page.

WherePairLightDark
Body textforeground on background18.60:1 · Lc 10516.10:1 · Lc 95
Secondary text on the pagemuted-foreground on background7.50:1 · Lc 869.35:1 · Lc 63
Text in cardscard-foreground on card17.30:1 · Lc 10014.71:1 · Lc 95
Secondary text in cardsmuted-foreground on card6.97:1 · Lc 818.54:1 · Lc 62
Menus and popoverspopover-foreground on popover17.30:1 · Lc 10014.71:1 · Lc 95
Primary buttonsprimary-foreground on primary4.56:1 · Lc 778.82:1 · Lc 62
Links and outline accentsprimary on background4.56:1 · Lc 718.96:1 · Lc 61
Secondary buttonssecondary-foreground on secondary16.78:1 · Lc 9813.75:1 · Lc 94
Text on muted panelsmuted-foreground on muted6.76:1 · Lc 797.98:1 · Lc 61
Hovered menu itemsaccent-foreground on accent8.16:1 · Lc 818.95:1 · Lc 71
Error messagesdestructive on background6.58:1 · Lc 819.02:1 · Lc 61
Sidebarsidebar-foreground on sidebar17.97:1 · Lc 10315.19:1 · Lc 95
Sidebar active itemsidebar-primary-foreground on sidebar-primary4.56:1 · Lc 778.82:1 · Lc 62
Sidebar hoversidebar-accent-foreground on sidebar-accent16.78:1 · Lc 9813.75:1 · Lc 94
Focus ringring on background18.60:15.75:1

Use it

With the shadcn CLI, in a project set up with shadcn init:

npx shadcn@latest add https://www.themes.dev/r/presets/margin.json

Or paste the CSS into globals.css (Next.js) or your main stylesheet (Vite, Astro), replacing the :root and .dark values that are there.

Then load the font:

npm i @fontsource-variable/hanken-grotesk

The registry item: themes.dev/r/presets/margin.json. Free to use in any project.

globals.css
:root {
  --radius: 0.875rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.186 0.007 258.37);
  --card: oklch(0.975 0.003 286.35);
  --card-foreground: oklch(0.186 0.007 258.37);
  --popover: oklch(0.975 0.003 286.35);
  --popover-foreground: oklch(0.186 0.007 258.37);
  --primary: oklch(0.58 0.18 285.08);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.965 0.004 0);
  --secondary-foreground: oklch(0.186 0.007 258.37);
  --muted: oklch(0.965 0.004 0);
  --muted-foreground: oklch(0.448 0.013 256.75);
  --accent: oklch(0.95 0.024 291.04);
  --accent-foreground: oklch(0.412 0.194 277.41);
  --destructive: oklch(0.5 0.182 29.51);
  --border: oklch(0.919 0.006 274.96);
  --input: oklch(0.557 0.014 255.56);
  --ring: oklch(0.186 0.007 258.37);
  --chart-1: oklch(0.804 0.103 285.91);
  --chart-2: oklch(0.66 0.166 285.08);
  --chart-3: oklch(0.56 0.151 285.08);
  --chart-4: oklch(0.47 0.137 285.08);
  --chart-5: oklch(0.39 0.122 285.08);
  --sidebar: oklch(0.988 0 0);
  --sidebar-foreground: oklch(0.186 0.007 258.37);
  --sidebar-primary: oklch(0.58 0.18 285.08);
  --sidebar-primary-foreground: oklch(1 0 0);
  --sidebar-accent: oklch(0.965 0.004 0);
  --sidebar-accent-foreground: oklch(0.186 0.007 258.37);
  --sidebar-border: oklch(0.919 0.006 274.96);
  --sidebar-ring: oklch(0.186 0.007 258.37);
}

.dark {
  --background: oklch(0.177 0.007 258.37);
  --foreground: oklch(0.945 0.003 128.49);
  --card: oklch(0.221 0.009 255.61);
  --card-foreground: oklch(0.945 0.003 128.49);
  --popover: oklch(0.221 0.009 255.61);
  --popover-foreground: oklch(0.945 0.003 128.49);
  --primary: oklch(0.773 0.121 286);
  --primary-foreground: oklch(0.186 0.007 258.37);
  --secondary: oklch(0.247 0.011 258.37);
  --secondary-foreground: oklch(0.945 0.003 128.49);
  --muted: oklch(0.247 0.011 258.37);
  --muted-foreground: oklch(0.777 0.012 252.12);
  --accent: oklch(0.281 0.06 283.22);
  --accent-foreground: oklch(0.843 0.083 289.06);
  --destructive: oklch(0.781 0.128 29.18);
  --border: oklch(0.3 0.012 258.37);
  --input: oklch(0.618 0.014 255.55);
  --ring: oklch(0.66 0.18 285.08);
  --chart-1: oklch(0.814 0.098 285.9);
  --chart-2: oklch(0.7 0.164 285.15);
  --chart-3: oklch(0.6 0.151 285.08);
  --chart-4: oklch(0.5 0.137 285.08);
  --chart-5: oklch(0.42 0.122 285.08);
  --sidebar: oklch(0.207 0.007 258.37);
  --sidebar-foreground: oklch(0.945 0.003 128.49);
  --sidebar-primary: oklch(0.773 0.121 286);
  --sidebar-primary-foreground: oklch(0.186 0.007 258.37);
  --sidebar-accent: oklch(0.247 0.011 258.37);
  --sidebar-accent-foreground: oklch(0.945 0.003 128.49);
  --sidebar-border: oklch(0.3 0.012 258.37);
  --sidebar-ring: oklch(0.66 0.18 285.08);
}

@theme inline {
  --font-sans: "Hanken Grotesk Variable", "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-heading: "Hanken Grotesk Variable", "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
}

The whole site

Margin started as Copybook, a website theme

Copybook is a complete site for Course providers and colleges: every page, the content model and a live demo, built from the same blocks, in Astro and Next.js + Sanity. It comes with UI Pro, from €199 once, with every other theme.

More shadcn/ui presets

All 37 presets