digdir / designsystemet

Designsystemet
https://designsystemet.no
MIT License
68 stars 34 forks source link

Redesign radio to match with checkbox #2111

Closed Febakke closed 17 hours ago

Febakke commented 3 weeks ago

When we implemented radio and checkbox with darkmode. We noticed that they dont match very well. We should try to alter the design of the radio button to handle darkmode better.

Elements we want

Image

Image

### Tasks
- [ ] Design new radiobutton component
Febakke commented 3 weeks ago

My first instinct is to add white to the "gap" inside the radiobutton. Hoping this would make the radio more visible and match with our checkbox. But this did not pan out. We have experience from working on focus indicators that radios get weird looking when you ad more circles.

Image

Next was to draw inspiration from other designsystems that support darkmode. And there are many ways that this can be handled. One is let the check and "gap" have the background color. As shown in the screenshot 👇 Image

They look better as a pair of components, but they are very subdued. I wish the selected inputs would be more visible.

We also looked into a outline versjon. But when you remove fill, they also get less visible and harder to read. Image

The version we have most hope for is the one inspired by Mantine. This will give us fill and a white indicator.

Image

Cons:

Example in light mode Image

Thuneer commented 3 weeks ago

I think we need to use the contrast color inside the radio button and the checkbox to make sure the contrast is sufficient in both light- and dark mode. Using just the background, as in the second example, is very problematic because a color cannot contrast properly against both dark and light colors at the same time. I like the Mantine example the most. Makes the checkbox and radio buttons fit together very nicely, and also makes sure contrasts work.

mrosvik commented 4 days ago

Should use token accent-contrast-1 to make sure it gets enough contrast. @Febakke

Barsnes commented 17 hours ago

This has been done in Figma, and in React #2130