|
| 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 | +/> |
0 commit comments