Skip to content

Commit a3758a2

Browse files
Barsneseirikbacker
andauthored
docs(blog): post about web components, or non-react, in DS (#4289)
Co-authored-by: eirikbacker <eirik.backer@mattilsynet.no>
1 parent 0509274 commit a3758a2

4 files changed

Lines changed: 139 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Web components and Designsystemet without React
3+
description: Soon you can use Designsystemet with both Svelte, Vue, Angular and all other technologies - also pure HTML and CSS. How will this be?
4+
date: 2025-12-17
5+
author: Designsystem
6+
imageSrc: /img/blog/web-components-25-en.png
7+
imageAlt: Illustration of web components
8+
---
9+
10+
Many have asked if Designsystemet will offer web components so that you can use the components without React. The answer is yes!
11+
But not everything will be web components. Let us explain why, and what we plan:
12+
13+
## Standards are good for everyone
14+
15+
Since the beginning, the goal has been to use web standards as much as possible, so that Designsystemet can be used in both old and new solutions,
16+
regardless of technology and framework. Many of the components actually already work in pure HTML. A good example is the button component:
17+
18+
```jsx
19+
// React:
20+
<Button variant="secondary">Click me</Button>
21+
22+
// HTML:
23+
<button class="ds-button" data-variant="secondary">Click me</button>
24+
```
25+
26+
In the HTML version, we use standard class names and data attributes.
27+
Not only does this work in all frameworks and equally well on both the server and in browsers - it also works for all users!
28+
Standard HTML has built-in support for screen readers, keyboard navigation, and other assistive technologies, without the need for additional customizations.
29+
30+
## Why not make everything as web components?
31+
32+
Web components are a relatively new standard that makes it possible to create your own HTML elements with encapsulated functionality and style using JavaScript.
33+
Although it may seem tempting to create a web component out of everything, for example a custom button:
34+
35+
```html
36+
<ds-button data-variant="secondary">Click me</ds-button>
37+
```
38+
39+
...this would cause us to lose much of the built-in accessibility that regular HTML gives us for free.
40+
In addition, we get worse performance, since we become dependent on JavaScript, and you as a developer can no longer use HTML documentation to understand the code.
41+
42+
In short: Many components simply do not need to - and should not - be web components.
43+
Modern CSS with class names and data attributes, in many cases provides both better flexibility and better performance.
44+
45+
## Which components will become web components?
46+
47+
Components that currently use React to implement logic will be made available as web components.
48+
For example, `<ds-field>` will connect form fields with `<label>` and error messages, and
49+
`<ds-tabs>` will handle tab navigation and associated content.
50+
51+
Other components, such as `Popover` and `Dialog`, do not need to become web components, because the web standard already
52+
offers `events` or the [`command` attributes (chrome.com)](https://developer.chrome.com/blog/command-and-commandfor) (with associated [polyfill (github.com)](https://github.com/keithamus/invokers-polyfill)) that we can use to help with opening and closing, and positioning.
53+
54+
Regardless of the technical solution, all components will be based on pure HTML,
55+
work across technologies, and have the same API:
56+
You use class names to select components, and data attributes to control settings and behavior.
57+
58+
## Timeline and input!
59+
60+
The work to make Designsystemet available without React will start in January 2026.
61+
62+
We will continuously release experimental versions so you can quickly test and provide feedback.
63+
64+
If you have any input or thoughts, we would greatly appreciate it if you would share them with us - either on [GitHub](https://github.com/digdir/designsystemet) or on [Slack](/slack).
65+
66+
<Contributors
67+
authors={[
68+
'Tobias Barsnes',
69+
'Eirik Backer',
70+
]}
71+
/>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Webkomponentar og Designsystemet utan React
3+
description: Snart kan du bruka designsystemet med både Svelte, Vue, Angular og alle andre teknologiar - også rein HTML og CSS. Korleis blir dette?
4+
date: 2025-12-17
5+
author: Designsystemet
6+
imageSrc: /img/blog/web-components-25-no.png
7+
imageAlt: Illustrasjon av webkomponentar
8+
---
9+
10+
Mange har spurt om Designsystemet kjem til å tilby webkomponentar slik at ein kan bruke komponentane utan React. Svaret er ja!
11+
Men ikkje alt vil vere webkomponentar. La oss forklare kvifor, og kva me planlegg:
12+
13+
## Standardar er bra for alle
14+
15+
Sidan starten har målet vore å nytte webstandardar så langt det let seg gjere, slik at Designsystemet kan brukast både i gamle og nye løysingar,
16+
uavhengig av teknologi og rammeverk. Mange av komponentane fungerer faktisk allereie i rein HTML. Eit godt døme er knappekomponenten:
17+
18+
```jsx
19+
// React:
20+
<Button variant="secondary">Klikk meg</Button>
21+
22+
// HTML:
23+
<button class="ds-button" data-variant="secondary">Klikk meg</button>
24+
```
25+
26+
I HTML-versjonen nyttar vi standard klassenamn og data-attributt.
27+
Ikkje berre fungerer dette i alle rammeverk og like godt både på server og i nettlesar - det fungerer òg for alle brukarar!
28+
Standard HTML har nemleg innebygd støtte for skjermlesarar, tastaturnavigasjon og andre hjelpeteknologiar, utan behov for ekstra tilpassingar.
29+
30+
## Kvifor ikkje lage alt som webkomponentar?
31+
32+
Webkomponentar er ein relativt ny standard som gjer det mogleg å lage eigne HTML-element med innkapsla funksjonalitet og stil ved hjelp av JavaScript.
33+
Sjølv om det kan verke freistande å lage webkomponentar av alt, til dømes ein eigen knapp:
34+
35+
```html
36+
<ds-button data-variant="secondary">Klikk meg</ds-button>
37+
```
38+
39+
...ville dette ført til at vi mistar mykje av den innebygde tilgjengelegheita som vanleg HTML gir oss gratis.
40+
I tillegg får vi dårlegare ytelse, sidan vi blir avhengige av JavaScript, og du som utviklar kan ikkje lenger nytte HTML-dokumentasjon for å forstå koden.
41+
42+
Kort sagt: Mange komponentar treng - og bør - rett og slett ikkje vere webkomponentar.
43+
Moderne CSS med klassenamn og data-attributt, gir i mange tilfelle både betre fleksibilitet og betre ytelse.
44+
45+
## Kva komponentar vil bli webkomponentar?
46+
47+
Komponentar som i dag nyttar React for å implementere logikk, vil bli tilgjengelege som webkomponentar.
48+
Til dømes vil `<ds-field>` kople saman skjemafelt med `<label>` og feilmeldingar, og `<ds-tabs>` vil handtere tab-navigasjon og tilhøyrande innhald.
49+
50+
Andre komponentar, som `Popover` og `Dialog`, treng ikkje bli webkomponentar, fordi web standarden allereie
51+
tilbyr `events` eller moderene [`command`-attributtar (chrome.com)](https://developer.chrome.com/blog/command-and-commandfor) (med tilhøyrende [polyfill (github.com)](https://github.com/keithamus/invokers-polyfill)) som vi kan nytte for å hjelpe med opning og lukking, og plassering.
52+
53+
Uavhengig av teknisk løysing vil alle komponentane vere baserte på rein HTML, fungere på tvers av teknologiar og ha det same API-et:
54+
Du nyttar klassenamn for å velje komponent, og data-attributt for å styre innstillingar og åtferd.
55+
56+
## Tidslinje og innspel!
57+
58+
Arbeidet med å gjere Designsystemet tilgjengeleg utan React startar januar 2026.
59+
Me vil fortløpande leggje ut eksperimentelle versjonar, slik at du raskt kan teste og kome med tilbakemeldingar.
60+
61+
Har du innspel eller tankar, set vi stor pris på om du deler dei med oss - anten på [GitHub](https://github.com/digdir/designsystemet) eller på [Slack](/slack).
62+
63+
<Contributors
64+
authors={[
65+
'Tobias Barsnes',
66+
'Eirik Backer',
67+
]}
68+
/>
123 KB
Loading
121 KB
Loading

0 commit comments

Comments
 (0)