---
title: "Setup"
description: "Get started with the Designsystemet in code"
url: "/en/fundamentals/code/setup"
language: "en"
---

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.

**HTML and other frameworks**

```sh
npm i @digdir/designsystemet-css @digdir/designsystemet-web

```

**React**

```sh
npm i @digdir/designsystemet-css @digdir/designsystemet-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

**HTML and other frameworks**

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

```js
import "@digdir/designsystemet-web";

```

**React**

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

```tsx
import { Button } from "@digdir/designsystemet-react";

```

## 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.

**CSS**

```css
@import "@digdir/designsystemet-css/index.css";
@import "@digdir/designsystemet-css/theme.css";

```

**JavaScript**

```js
import "@digdir/designsystemet-css";
import "@digdir/designsystemet-css/theme";

```

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](/en/fundamentals/start-here/own-theme.md).

Use your own theme

Replace the default theme import with your generated CSS file:

```css
@import "@digdir/designsystemet-css/index.css";
@import "./designsystemet/my-theme.css";

```

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](/en/fundamentals/code/css.md) 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:

**HTML and other frameworks**

```html
<div data-color-scheme="auto" data-size="md">
  <ds-field class="ds-field">
    <label class="ds-label" for="name">Name</label>
    <input class="ds-input" id="name" name="name" type="text" />
  </ds-field>
  <button class="ds-button" data-variant="secondary" type="button">
    Continue
  </button>
</div>

```

**React**

```tsx
import { Button, Field, Input, Label } from "@digdir/designsystemet-react";

export function Example() {
  return (
    <div data-color-scheme="auto" data-size="md">
      <Field>
        <Label>Name</Label>
        <Input name="name" type="text" />
      </Field>
      <Button variant="secondary">Continue</Button>
    </div>
  );
}

```

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](/en/components.md) for more examples, and [patterns](/en/patterns.md) for help putting them together. Each component also has an accessibility page.

## Using AI assistance

Give your AI tool [our documentation index](/llms.txt). Pages are also available as Markdown: add `.md` to the URL, as in [setup.md](/en/fundamentals/code/setup.md), or request `Accept: text/markdown`.

Ask it to use your project's package versions and follow our [patterns](/en/patterns.md). 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.

**HTML and other frameworks**

```json
{
  "compilerOptions": {
    "types": ["@digdir/designsystemet-web", "@digdir/designsystemet-css/theme"]
  }
}

```

**React**

```json
{
  "compilerOptions": {
    "types": [
      "@digdir/designsystemet-react/react-types",
      "@digdir/designsystemet-css/theme"
    ]
  }
}

```

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](/en/fundamentals/code/cli-config.md#output).

## Font

The default theme uses [Inter](https://github.com/rsms/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](https://www.joshtumath.uk/posts/2026-07-02-lets-fix-the-webs-text-size/):

```html
<meta name="text-scale" content="scale" />

```

### Add the Inter font (optional)

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

```html
<link
  rel="stylesheet"
  href="https://altinncdn.no/fonts/inter/v4.1/inter.css"
  integrity="sha384-OcHzc/By/OPw9uJREawUCjP2inbOGKtKb4A/I2iXxmknUfog2H8Adx71tWVZRscD"
  crossorigin="anonymous"
/>

```

### 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`.

```css
body {
  font-family: var(--ds-font-family), sans-serif;
  font-feature-settings: "cv05" 1; /* Enable lowercase l with tail */
}

```

## 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`:

```ts
// Polyfill missing HTMLDocument to Document inheritance in HappyDOM
if (
  typeof HTMLDocument !== "undefined" &&
  typeof Document !== "undefined" &&
  HTMLDocument.prototype !== Document.prototype &&
  !(Document.prototype instanceof HTMLDocument) &&
  !(HTMLDocument.prototype instanceof Document)
) {
  Object.setPrototypeOf(HTMLDocument.prototype, Document.prototype);
}

```

JSDOM setup

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

```ts
// Minimal test mocks, not browser-equivalent dialog behaviour.
if (typeof HTMLDialogElement.prototype.show !== "function") {
  HTMLDialogElement.prototype.show = function () {
    this.open = true;
  };
}

if (typeof HTMLDialogElement.prototype.showModal !== "function") {
  HTMLDialogElement.prototype.showModal = function () {
    this.open = true;
  };
}

if (typeof HTMLDialogElement.prototype.close !== "function") {
  HTMLDialogElement.prototype.close = function (returnValue?: string) {
    this.open = false;
    if (returnValue !== undefined) this.returnValue = returnValue;
    this.dispatchEvent(new Event("close"));
  };
}

```

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](https://designsystemet.no/slack) or [report an issue](https://github.com/digdir/designsystemet/issues/new/choose).

[Edit this page on github.com (opens in a new tab)](https://github.com/digdir/designsystemet/tree/main/apps/www/app/content/fundamentals/en/code/setup.mdx)