Foundation
ColorThemes replaces Tailwinds default colors and map primitive scales to stable semantic tokens available for all Tailwind prefixes.
Importing themes
Tailwind 4 is required – If your project isn’t on Tailwind 4, please upgrade before proceeding.
Tailwind 4 Setup
Since Tailwind 4 merges configs automatically, you won’t need a separate tailwind.config.js in your project. Instead, ensure Tailwind 4 is set up in your main .css file (or in your chosen bundler config).
Below are examples for Next.js:
- Install the necessary Tailwind 4 packages (if you haven’t already):
pnpm install tailwindcss @tailwindcss/postcss postcss- Import your chosen themes in global.css:
@import 'tailwindcss';
// Always import base.css to get all colors and utilities
@import '@svs/ui/tailwind/base.css';
// Always import font.css to get Svenska Spel's custom font
@import '@svs/ui/tailwind/nextjs/font.css';
@import '@svs/ui/tailwind/oddset.css';
/* If you are using components from the svs-ui
add them as source so Tailwind can find and purge properly */
@source "../../../../packages/ui/";
/* Optional */
body {
@apply bg-surface-base;
}- To use a theme in your project, simply wrap a high-level node in your application with the theme className of your choice. For example, to use the light theme for our primary product, you would wrap your application in a div with the className "theme-primary-light":
<div className="theme-svs-light">
{/* Your application components go here */}
</div>Use multiple themes
It is possible to nest themes to use multiple themes in the same application. For example, you could have a section of your application that uses the vibrant theme while the rest of the application uses the light theme:
<div className="theme-svs-light">
{/* Light themed components */}
<div className="theme-svs-vibrant">
{/* Vibrant themed components */}
</div>
</div>Convention
We use a simple color and fg convention for colors where the background is set with the name of the color and text, icons and other elements placed on a background uses the -fg (foreground) variant of the same color.
Below is a list of classNames you can copy and paste for each color. The first example shows which parts are Tailwind prefixes and which parts are variables from @svs/ui themes.
Accent colors
Accent colors are used to give the interface a distinct product identity.
Note that not all themes has mapped colors for secondary-variant and tertiary colors
Primary
bg-primary text-primary-fg hover:bg-primary-hover active:bg-primary-pressedPrimary-variant
bg-primary-variant text-primary-variant-fg hover:bg-primary-variant-hover active:bg-primary-variant-pressedSecondary
bg-secondary text-secondary-fg hover:bg-secondary-hover active:bg-secondary-pressedSecondary-variant
bg-secondary-variant text-secondary-variant-fg hover:bg-secondary-variant-hover active:bg-secondary-variant-pressedTertiary
bg-tertiary text-tertiary-fg hover:bg-tertiary-hover active:bg-tertiary-pressedTertiary-variant
bg-tertiary-variant text-tertiary-variant-fg hover:bg-tertiary-variant-hover active:bg-tertiary-variant-pressedStatus colors
Use to indicate a message to the user.
Success
bg-success text-success-fg hover:bg-success-hover active:bg-success-pressedSuccess variant
bg-success-variant text-success-variant-fg hover:bg-success-variant-hover active:bg-success-variant-pressedAttention
bg-attention text-attention-fg hover:bg-attention-hover active:bg-attention-pressedAttention variant
bg-attention-variant text-attention-variant-fg hover:bg-attention-variant-hover active:bg-attention-variant-pressedImportant
bg-important text-important-fg hover:bg-important-hover active:bg-important-pressedImportant variant
bg-important-variant text-important-variant-fg hover:bg-important-variant-hover active:bg-important-variant-pressedSurfaces
Surfaces are the foundational backgrounds for larger UI elements or sections. All surfaces share the same foreground: text-surface-fg
Surface-base
bg-surface-base text-surface-fgSurface-standard
bg-surface-standard text-surface-fgSurface-elevated
bg-surface-elevated text-surface-fg text-surface-fgSurface-inverted
bg-surface-inverted text-surface-inverted-fgbg-surface-inverted surface-inverted-primary-fgLayers
All layers share the same foreground: text-layer-fg. Layers are placed upon surfaces.
Layer-neutral is an opacity based layer suitable for both surface-standard and surface-base.
Neutral
bg-layer-neutral hover:bg-layer-neutral-hover active:bg-layer-neutral-pressed text-layer-fgContrast-on-base
bg-layer-contrast-on-base hover:bg-layer-contrast-on-base-hover active:bg-layer-contrast-on-base-pressed text-layer-fgContrast-on-surface
bg-layer-contrast-on-surface hover:bg-layer-contrast-on-surface-hover active:bg-layer-contrast-on-surface-pressed text-layer-fgTransparent
bg-layer-transparent text-surface-fg hover:bg-layer-transparent-hover active:bg-layer-transparent-pressed selected:bg-layer-transparent-selectedStroke
Use borders according to Tailwinds defaults and set any of the colors below. i.e className="border-4 border-stroke-low"
border-stroke-lowborder-stroke-mediumborder-stroke-highLinks
link-default
link-primary
Do and don't
theme-[product]-lighttheme-dark for global dark preferencetheme-[product]-lighttheme-dark for global dark preference