Skip to content

[TextField] snapOnStep prop #45856

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

Closed
shifoc opened this issue Apr 9, 2025 · 7 comments
Closed

[TextField] snapOnStep prop #45856

shifoc opened this issue Apr 9, 2025 · 7 comments
Labels
component: text field This is the name of the generic UI component, not the React module!

Comments

@shifoc
Copy link

shifoc commented Apr 9, 2025

Summary

Would it be possible to add this behavior:

The new snapOnStep prop is a boolean:

true: the value is snapped to the nearest step when stepping (incrementing/decrementing). So 1.07 with a step of 1 becomes 2 when incrementing
false (new default): the value isn't snapped at all. So 1.07 with a step of 1 becomes 2.07.

Examples

mui/base-ui#1560

        <TextField
          id="outlined-number"
          label="Number"
          type="number"
          slotProps={{
            inputLabel: {
              shrink: true,
            },
            htmlInput: { step: 0.25 }
          }}
        />

Motivation

No response

Search keywords: TextField, step, snapOnStep

@shifoc shifoc added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 9, 2025
@sai6855
Copy link
Contributor

sai6855 commented Apr 9, 2025

Could you post a reproduction, either a Github repo or Codesandbox/Stackblitz and detailed steps on issue you are facing?

@sai6855 sai6855 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 9, 2025
@shifoc
Copy link
Author

shifoc commented Apr 9, 2025

Could you post a reproduction, either a Github repo or Codesandbox/Stackblitz and detailed steps on issue you are facing?

mui/base-ui#1560

This is exactly what I want

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Apr 9, 2025
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Apr 10, 2025

@shifoc For which component? NumberField isn't available in Material UI. Please provide proper details before opening an issue. You can re-open this issue once you provide proper details in the issue description.

Copy link

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.

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 10, 2025
@shifoc shifoc changed the title is there a way to snap the value when using the step? [TextField] snapOnStep prop Apr 10, 2025
@shifoc
Copy link
Author

shifoc commented Apr 10, 2025

@ZeeshanTamboli Sorry! I updated the description but I don't have permission to reopen the issue

@ZeeshanTamboli
Copy link
Member

@shifoc We don’t recommend using type="number" with TextField — see the docs: https://mui.com/material-ui/react-text-field/#type-quot-number-quot. We will be adding the new Number Field component to Material UI in the near future.

Copy link

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.

@zannager zannager added the component: text field This is the name of the generic UI component, not the React module! label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

4 participants