-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
feat: number-field component #4575
Conversation
@thejasonxie is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
Sorry, don't merge yet because there is a bug. I also think using react-aria's useNumberField hook is better. Fill fix soon. |
6007c6c
to
89addef
Compare
I changed my mind on using react-aria as the installation comes with much more than just the useNumberField hook. I fixed the bug I was having with controlled state and used react-number-format's useNumericFormat hook instead for full customization. The merge is good to go once reviewed. Thanks! |
Given its popularity, it would be great if Shadcn UI could encourage the use of libraries that have good accessibility and internationalization support. React Aria's number field has been carefully designed to handle those concerns. See our blog post: https://react-spectrum.adobe.com/blog/how-we-internationalized-our-numberfield.html Looking through the source code for react-number-format I see a lot of hard coded assumptions about the format and numbering system, e.g. decimals, negative signs, latin numerals, etc. It is also missing accessibility support to ensure the values are clearly announced to screen reader users. Let me know if I can help with React Aria in any way. Would be amazing to collaborate on this. |
@devongovett Yeah I agree, React Aria's number field component/hook would have been better to use in my opinion. The only thing that stopped me from using it is because the React Aria installation comes with a bunch of other React Aria's components when Shadcn is Radix based. It would be nice if React Aria can provide a way to install components individually. |
hmm yeah, you can do that with the hooks - |
Oh great, I didn't know |
@devongovett was about to refactor but someone made a PR with react-aria's NumberField component. Probably better than my code if I were to refactor 😂, so i'll be closing this PR. |
Needed a nice number input.
Saw that #1818 is becoming stale.
Took inspiration from shadcn's example in that stale PR to create one.
Used react-number-format to handle number formatting
Usage: