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

Expose formatOptions of NumberInput #991

Closed
marcopiii opened this issue Mar 17, 2025 · 0 comments · Fixed by #992
Closed

Expose formatOptions of NumberInput #991

marcopiii opened this issue Mar 17, 2025 · 0 comments · Fixed by #992
Labels

Comments

@marcopiii
Copy link
Member

The component NumberInput internally determines the number's format using the hook useFormatOptions.

export function useFormatOptions({ kind }: FormatProps) {
// This function must be memoized, see this relevant issue:
// https://github.com/adobe/react-spectrum/issues/1893
return useMemo((): Intl.NumberFormatOptions | undefined => {
switch (kind) {
case "currency":
return {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
};
case "percentage":
case "decimal":
case undefined:
return undefined;
}
}, [kind]);
}

The kind property defines it, and there is no way to alter it via the NumberInput's API.

It would be very useful to be able to customize the format options.

@marcopiii marcopiii added the WIP label Mar 17, 2025
marcopiii added a commit that referenced this issue Mar 25, 2025
…rinput

#991: Expose `formatOptions` of `NumberInput`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant