-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Description
What's the problem? 🤔
When switching a variant from plain|solid|soft
to outlined
the box-model of the component is changing due to the use of border.
This is a common issues in many UI libraries
Recording.2023-10-21.142031.mp4
What are the requirements? ❓
As a Developer,
I want to switch variant without changes in the box-model,
So that I can use them all in the same way.
Given the component uses variant "soft"
When I hover the component
Then the component should use variant "outlined"
And the component should keep its box-model
And the page flow should persist
What are our options? 💡
The only solution to this problem is to manually overwrite every component and therefore causing a potentially unmaintaiable problem (not future-safe, will not affect newly added components)
Proposed solution 🟢
- Personally I've been using
box-shadow
for decorative outlines such as "Ghost buttons" for a decade. - If
box-shadow
does not satisfy the methodology of this library you could use a transparent border or use the background-color (this should be easy to implement due to the use of css-variables/custom-properties). It would then be applied to all variant, therefore ensuring a stable and consistent box-model.
Resources and benchmarks 🔗
Sadly I am not aware of any libraries that solve this problem efficiently.
mui/material and mui/joy both have this problem, while I'm only proposing this for the new standard JOY.