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] Arbitrarily restrict the possible values of the slider #412

Open
mj12albert opened this issue May 24, 2024 · 1 comment
Open

[Slider] Arbitrarily restrict the possible values of the slider #412

mj12albert opened this issue May 24, 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

Comments

@mj12albert
Copy link
Member

mj12albert commented May 24, 2024

Currently the marks and step props are used together to restrict the possible values of the slider to some arbitrary numbers like this:

<Slider
  marks={[
   { value: 2, label: '2' },
   { value: 3, label: '3' },
   { value: 5, label: '5' },
   { value: 11, label: '11' }
  ]}
  step={null}
 />

(Here is a full demo from the docs)

However it doesn't make sense to have marks, which should be only about the visual marks, dictate the step.

We decided to redesign this feature using the component-per-node API, e.g.:

<Slider.Root defaultValue={5}>
  <Slider.Track>
    <Slider.Thumb />
    <Slider.RestrictedValue value={2} />
    <Slider.RestrictedValue value={3} />
    <Slider.RestrictedValue value={5} />
    <Slider.RestrictedValue value={11} />
  </Slider.Track>
</Slider.Root>
  • If any RestrictedValue component is present, the step prop should be ignored
  • The RestrictedValue component could render a span with some minimal positioning styles

Search keywords:

@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 May 24, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented May 28, 2024

However it doesn't make sense to have marks, which should be only about the visual marks, dictate the step.

I don't understand why it doesn't make sense. I see marks like legends, they can help people know where they are, e.g. https://mui.com/material-ui/react-slider/#custom-marks. It feels like the same use case as in https://mui.com/x/react-charts/scatter/#grid.

What do the Google Analytics events between the two demos in https://mui.com/base-ui/react-slider/#discrete-sliders say?

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
Projects
None yet
Development

No branches or pull requests

2 participants