Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Slider] Support for marks #462

Open
mj12albert opened this issue Jun 20, 2024 · 1 comment
Open

[Slider] Support for marks #462

mj12albert opened this issue Jun 20, 2024 · 1 comment
Labels
component: slider This is the name of the generic UI component, not the React module! new feature New feature or request waiting for 👍 Waiting for upvotes

Comments

@mj12albert
Copy link
Member

mj12albert commented Jun 20, 2024

Feature request

Summary

Introduce a new API consistent with component-per-node design to support rendering marks on the slider Track, as the marks prop and Mark component/slot was removed in #216

While it's quite simple to implement this (including "inverted track", demo) using useSliderContext, we have decided that all the hooks are private for now

In the native <input type='range' />, we can do it by adding a and linking it with the id.

<input type="range" min="-100" max="100" value="0" step="10" name="power" list="powers">
<datalist id="powers">
   <option value="0">
   <option value="-30">
   <option value="30">
   <option value="++50">
</datalist>

The Slider should also snap to the closest marker/indicator.

Examples in other libraries

MUI - https://mui.com/material-ui/react-slider/#discrete-sliders

Mantine - https://mantine.dev/core/slider/#marks

ARK UI - https://ark-ui.com/react/docs/components/slider#adding-marks

Chakra UI - https://www.chakra-ui.com/docs/components/slider#marks

@mj12albert mj12albert added component: slider This is the name of the generic UI component, not the React module! new feature New feature or request labels Jun 20, 2024
@mj12albert
Copy link
Member Author

@siriwatknp suggested exposing the slider's percentage value(s) as CSS vars as alternative to providing a marks subcomponent, it would be enough to enable adding visual marks on the track using CSS alone

This would nicely sidestep the problem of defining an arbitrary number of marks with a composition API without using (mandatory) loops/function children

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! new feature New feature or request waiting for 👍 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

1 participant