Components
Spinner
Spinner is used to indicate that content or an action is loading, and that the user must wait before they can continue.
<svg
aria-label="Loading coffee"
class="ds-spinner"
role="img"
viewBox="0 0 50 50"
>
<circle
class="ds-spinner__background"
cx="25"
cy="25"
r="20"
fill="none"
stroke-width="5"
></circle>
<circle
class="ds-spinner__circle"
cx="25"
cy="25"
r="20"
fill="none"
stroke-width="5"
></circle>
</svg>const PreviewEn = () => { return <Spinner aria-label='Loading coffee' />; }; render(<PreviewEn />)
Usage
Add the class name ds-spinner to an <svg> tag to create a spinner.
The <svg> should have two <circle> elements inside it to create the spinner.
CSS variables and data attributes
Sizes are controlled with data-size and colors with data-color. The component will inherit from the closest parent where these are set.
| Name | Value |
|---|---|
| --dsc-spinner-animation-duration | 2s |
| --dsc-spinner-background | var(--ds-color-surface-tinted) |
| --dsc-spinner-stroke | var(--ds-color-border-default) |
No relevant data attributes found.
React
import { Spinner } from "@digdir/designsystemet-react";
<Spinner aria-label="Loader" />;
Spinner
- aria-label
- Description
Accessibile label Defines a string value that labels the current element. @see aria-labelledby.
- Type
string
| Name | Type | Default | Description |
|---|---|---|---|
| aria-label | string | - | Accessibile label Defines a string value that labels the current element. @see aria-labelledby. |