ui icon indicating copy to clipboard operation
ui copied to clipboard

feat(slider): add vertical slider support and update docs

Open xmliszt opened this issue 1 year ago • 13 comments

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 a slider-vertical-demo
  • Slider component is updated in both default and new-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 has h-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 optional orientation="vertical" to create a vertical slider. Also added examples to our sink

CleanShot 2024-01-27 at 03 28 11

Demo

shadcn slider demo

video demo link: https://github.com/shadcn-ui/ui/assets/44829092/dd3f5e3f-b37a-4ac1-8b4a-6bf213c69a51

xmliszt avatar Jan 26 '24 19:01 xmliszt

@xmliszt is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jan 26 '24 19:01 vercel[bot]

Can you merge this please? @shadcn

jogamod avatar Feb 04 '24 21:02 jogamod

kindly bumping @shadcn

DenizUgur avatar Mar 11 '24 04:03 DenizUgur

Rebased to resolve conflicts

xmliszt avatar Mar 11 '24 11:03 xmliszt

Bump

magoz avatar Mar 22 '24 12:03 magoz

Bump

jdecorte-be avatar Apr 02 '24 13:04 jdecorte-be

Resolved conflicts & comments. Updated sink to have a better use case of vertical slider like this shown below (maybe like music app equalizer)

CleanShot 2024-04-15 at 15 43 32@2x

xmliszt avatar Apr 15 '24 07:04 xmliszt

A volume slider on a custom video player might be a use case as well.

DenizUgur avatar Apr 15 '24 07:04 DenizUgur

Thanks for approval. Anyone knows how to kickstart the workflows? Seems like it still needs authorization to proceed. 🙏🏻

xmliszt avatar Apr 15 '24 14:04 xmliszt

Hi @shadcn , may I kindly ask for your review and approval to run the deployment pipeline please? 🙏🏻 Thank you so much!

xmliszt avatar May 16 '24 12:05 xmliszt

Would like to see this get implemented as well! Useful for different use-cases

timsun28 avatar Jul 01 '24 15:07 timsun28

bump

hoangvu12 avatar Jul 31 '24 17:07 hoangvu12