ui
ui copied to clipboard
feat(slider): add vertical slider support and update docs
This PR adds vertical slider support for the <Slider>
component. It closes #2186
Intuition
radix/primitive
slider comes with both "horizontal" and "vertical" support, it injects the orientation prop as data-orientation
attribute to the primitive components. Hence, I think it is straight-forward and simpler for us to just tap on the data-orientation
attribute to change our component classes accordingly using Tailwind's built-in data-*
modifier (see: https://tailwindcss.com/docs/hover-focus-and-other-states#attribute-selectors )
Changes
- The previous slider demo is refactored into
slider-horizontal-demo
and I created aslider-vertical-demo
- Slider component is updated in both
default
andnew-york
to support vertical orientation - We follow the original slider implementation, that is, the slider itself does not hard-code its width / height, but it should be following its parent container. (e.g. a horizontal slider has
w-full
, or a vertical slider hash-full
) So it is parent's container's responsibility to determine the width of the horizontal slider, or the height of the vertical slider. - Updated
docs/component/slider.mdx
to showcase both horizontal and vertical slider sample codes, as well as explaining the usage of setting optionalorientation="vertical"
to create a vertical slider. Also added examples to our sink
Demo
video demo link: https://github.com/shadcn-ui/ui/assets/44829092/dd3f5e3f-b37a-4ac1-8b4a-6bf213c69a51
@xmliszt is attempting to deploy a commit to the shadcn-pro Team on Vercel.
A member of the Team first needs to authorize it.
Can you merge this please? @shadcn
kindly bumping @shadcn
Rebased to resolve conflicts
Bump
Bump
Resolved conflicts & comments. Updated sink to have a better use case of vertical slider like this shown below (maybe like music app equalizer)
A volume slider on a custom video player might be a use case as well.
Thanks for approval. Anyone knows how to kickstart the workflows? Seems like it still needs authorization to proceed. 🙏🏻
Hi @shadcn , may I kindly ask for your review and approval to run the deployment pipeline please? 🙏🏻 Thank you so much!
Would like to see this get implemented as well! Useful for different use-cases
bump