Customize theme

Colours, sizes and motion are CSS variables with the --ads- prefix. Override any of them in your own CSS.

Overriding tokens

Declare the variables you need after importing tokens.css. Hover and pressed states have their own -solid-hover and -solid-active tokens:

:root {
  --ads-radius-md: 8px;
  --ads-control-height: 36px;
  --ads-color-primary-solid: #1f5fd1;
}

:root[data-theme='dark'] {
  --ads-color-primary-solid: #5b9bff;
}

The dark theme tokens are declared in :root[data-theme="dark"] and have a higher specificity, so override colours for the dark theme with the same selector.

Main token groups

GroupExampleDescription
Colours--ads-color-primary-solidPalette, fills and text colours.
Sizes--ads-control-heightHeights and paddings of controls.
Radius--ads-radius-mdCorner radii.
Typography--ads-font-sizeFont family and sizes.
Motion--ads-motion-durationDurations and easing of transitions.

Accessible colours

The default light colours are the ones of the Ant Design documentation, so the library looks like Ant Design. They do not reach 4.5:1 for white text on a primary or danger fill, nor for links (4.10:1 on the primary fill). To get a guaranteed contrast, import tokens-accessible.css after tokens.css: fills use the -solid tokens, text on the page uses the -text and link tokens, and their pairs are checked for 4.5:1. The dark theme needs no extra file. Keep that contrast when you change colours.

import 'svelte-ant-design/tokens.css';
import 'svelte-ant-design/tokens-accessible.css';