Skip to main content

What are you looking for?

Try searching for…

Getting started

Setup

Get started with the Designsystemet in code

Updated October 25, 2026

Here is how to add Designsystemet to your project. The examples use npm and a build tool such as Vite.

1. Install the packages

The CSS package provides the look. The web and React packages add component behaviour. Choose HTML for plain HTML or frameworks such as Vue, Angular and Svelte, or choose React.

HTMLReact

HTML and other frameworks

React

You also need React and React DOM 18.3.1 or newer.

You can also use the web package with your own CSS, or use CSS alone if you handle the behaviour yourself.

2. Import JavaScript

HTMLReact

HTML and other frameworks

Add this once in your main JavaScript file. It needs to run in the browser.

React

Import the components you use. You do not need a separate import of the web package.

3. Add CSS and a theme

The theme sets colors, sizes and fonts. Start with the default theme below. Add these imports once, either in your main CSS file or through JavaScript. Keep them in this order.

CSSJavaScript

CSS

JavaScript

Import @digdir/designsystemet-css before your theme, so the order of our layers (@layer ds) is set first.

Want your own colors and fonts? Create your own theme.

Use your own theme

Replace the default theme import with your generated CSS file:

Replace my-theme.css with your filename and adjust the path to match your project.

CSS also sets the text and background colors on body. See the CSS guide if you use Tailwind, a CSS reset or want to change these defaults.

4. Use the components

Here is a field and a button to get you started:

HTMLReact

HTML and other frameworks

React

You can set colors and sizes on a component or a surrounding element:

  • data-color-scheme="auto" follows the user's light or dark mode. You can also choose light or dark.
  • data-size="md" sets the size. You can also choose sm or lg.
  • data-color="accent" sets the color. Available colors depend on your theme.

See components for more examples, and patterns for help putting them together. Each component also has an accessibility page.

Using AI assistance

Give your AI tool our documentation index. Pages are also available as Markdown: add .md to the URL, as in setup.md, or request Accept: text/markdown.

Ask it to use your project's package versions and follow our patterns. Review and test the result as you would other code.

TypeScript

The packages include types. To add support for web components or React data attributes and theme colors, add these entries to compilerOptions.types in tsconfig.json. Keep any entries you already have.

HTMLReact

HTML and other frameworks

React

For your own theme, replace @digdir/designsystemet-css/theme with the path to its types, for example ./designsystemet/types.d.ts. See how to generate theme types.

Font

The default theme uses Inter. You can use another font with your own theme. Include font weights 400, 500 and 600.

Text scaling that follows system settings

Add this to <head> to let browsers that support it follow the user's text size settings:

Add the Inter font (optional)

To load Inter from Altinn CDN, add this to <head>:

Use the font

Add this to your main CSS file to use your theme's font. font-feature-settings gives lowercase l a tail, making it easier to tell apart from uppercase I.

Testing

We test with JSDOM, HappyDOM and real browsers. JSDOM and HappyDOM do not support everything a browser does, so your tests may need the adjustments below.

HappyDOM setup

HappyDOM may require support for inheritance between HTMLDocument and Document:

JSDOM setup

JSDOM may lack dialog methods. If your version does, add only the missing mocks in your test setup:

Use a real browser to check keyboard navigation, focus, dialogs and popovers. The mocks above cannot check these for you. Need help? Ask in Slack or report an issue.

Edit this page on github.com (opens in a new tab)