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

[NumberField] Support custom decimal separator #1066

Open
Tockra opened this issue Dec 12, 2024 · 3 comments
Open

[NumberField] Support custom decimal separator #1066

Tockra opened this issue Dec 12, 2024 · 3 comments
Labels
component: number field This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Tockra
Copy link

Tockra commented Dec 12, 2024

Summary

When the Number Input support decimal numbers in future, it would be nice to control the separator.
E.g. by an optional property "separator: string" which allows to choose a own separator based on the websites locale. If not set it could determine the separator by the browser settings.

Examples

<NumberInput
  aria-label="Demo number input"
  placeholder="Type a number…"
  value={value}
  onChange={(event, val) => setValue(val)}
/> {// uses default browser locale}
<NumberInput
  aria-label="Demo number input"
  separator=","
  placeholder="Type a number…"
  value={value}
  onChange={(event, val) => setValue(val)}
/> {// accepts 1231,50 (means -> 1231.50)}
<NumberInput
  aria-label="Demo number input"
  separator="."
  placeholder="Type a number…"
  value={value}
  onChange={(event, val) => setValue(val)}
/> {// accepts 1231.50 }
<NumberInput
  aria-label="Demo number input"
  separator="#"
  placeholder="Type a number…"
  value={value}
  onChange={(event, val) => setValue(val)}
/> {// accepts 1231#50 (means -> 1231.50)}

Motivation

Multi language support of decimal numbers

Search keywords: separator, decimal, number, input,textfield

Search keywords:

@Tockra Tockra added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 12, 2024
@zannager zannager added the component: number field This is the name of the generic UI component, not the React module! label Dec 12, 2024
@mj12albert mj12albert transferred this issue from mui/material-ui Dec 12, 2024
@mj12albert mj12albert removed their assignment Dec 12, 2024
@mj12albert mj12albert changed the title Number Input - Allow to configure the decimal separator [NumberField] Support custom decimal separator Dec 12, 2024
@mj12albert mj12albert added the enhancement This is not a bug, nor a new feature label Dec 12, 2024
@mj12albert
Copy link
Member

@Tockra In the new API, we have a format prop that takes Intl.NumberFormat options:

<NumberField format={/* options */} />

Would that work for your use-case?

@Tockra
Copy link
Author

Tockra commented Dec 20, 2024

@Tockra In the new API, we have a format prop that takes Intl.NumberFormat options:

<NumberField format={/* options */} />

Would that work for your use-case?

Thank you for your answere. This prop seems to be good for my usecase.
Is it already present in the current stable mui version?

@mj12albert
Copy link
Member

Is it already present in the current stable mui version?

@base-ui-components/react is just released and you can try the NumberField now: https://base-ui.com/react/components/number-field

This will come to Material UI in an upcoming major release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: number field This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants