openui / open-ui

Maintain an open standard for UI and promote its adherence and adoption.
https://open-ui.org
Other
3.43k stars 183 forks source link

switch: What customizability for animations should be supported? #816

Open josepharhar opened 11 months ago

josepharhar commented 11 months ago

I am interested in nailing down what the use cases for <switch> are. It seems like rendering content on top of the two sides of the track and the thumb are important.

In @gfellerph's new switch explainer I saw this:

Findings (from 44 analyzed Design Systems):

  • 70% of Design Systems don’t display any content inside their switches
  • 30% display content on the track
  • 18% display content on the thumb
  • 88% use the background color transition animation
  • 16% use a track slide animation

For the "background color transition animation" and "track slide animation", does the design system allow the developer to customize the animation itself? Or does it just mean that the design system has an animation that is not customizable?

I am sure that <switch> will have an animation by default for these things, but do we need to provide developer controls to change how they work?

chrisdholt commented 11 months ago

I am sure that will have an animation by default for these things, but do we need to provide developer controls to change how they work?

I might be missing the intent of your question, so forgive me if that is the case :).

Even if design systems currently don't allow for the customization of the background animation, if we don't provide a method for developers to customize it wouldn't that prevent design systems authors from implementing their own custom animations?

josepharhar commented 11 months ago

Even if design systems currently don't allow for the customization of the background animation, if we don't provide a method for developers to customize it wouldn't that prevent design systems authors from implementing their own custom animations?

Yes it would! Can you think of any ways that a design system might want to customize the animations?

gfellerph commented 11 months ago

@josepharhar, Design Systems usually don't provide a way to customise the animation. The one example that offers a lot of variation is ant design system, where switches with content use the track slide animation and switches without content use the background transition. I think the default animation should be a background transition, due to popularity. The track slide animation should be something that authors can easily add (overriding the background transition).

Some track slide animations also have very slight variation with a parallax effect where content and track don't move at the same speed. In my understanding, it would complicate implementation a lot if there were two different animation techniques baked into the <switch>.