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] Formatting API for the value displayed in Slider.Output #459

Closed
mj12albert opened this issue Jun 18, 2024 · 2 comments
Closed

[Slider] Formatting API for the value displayed in Slider.Output #459

mj12albert opened this issue Jun 18, 2024 · 2 comments
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 Jun 18, 2024

Extension of #216

A format API/prop for slider could support these two cases:

1. Intl.NumberFormatOptions

For parity with NumberField:

<Slider.Root defaultValue={[50, 70]}>
  <Slider.Output format={{ style: 'currency', currency: 'USD' }} />
  {/*  other subcomponents */}
<Slider.Root>

renders

<output>$50.00 – $70.00</output>

2. Custom function

To support formats that are not provided by the Intl API, example:

<Slider.Root defaultValue={[50, 70]}>
  <Slider.Output format={(values) => `${values.map(val => `${val}`).join(' – ')}°C`} />
  {/*  other subcomponents */}
<Slider.Root>

renders

<output>50 – 70°C</output>

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 Jun 18, 2024
@mj12albert
Copy link
Member Author

Superceded by #961

Copy link

github-actions bot commented Dec 5, 2024

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

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

1 participant