Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/www/src/app/examples/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const Page = () => {
required: true,
selected: new Date()
}}
inputFieldProps={{
inputProps={{
size: 'small'
}}
/>
Expand Down Expand Up @@ -315,7 +315,7 @@ const Page = () => {
endMonth: dayjs('2027-12-01').toDate(),
defaultMonth: dayjs('2027-11-01').toDate()
}}
inputFieldsProps={{
inputsProps={{
startDate: {
size: 'small'
},
Expand Down
18 changes: 14 additions & 4 deletions apps/www/src/content/docs/components/number-field/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ export const composedDemo = {

export const formatDemo = {
type: 'code',
code: `<NumberField
defaultValue={1000}
format={{ style: 'currency', currency: 'USD' }}
/>`
tabs: [
{
name: 'System locale (default)',
code: `<NumberField defaultValue={1000} format={{ style: 'currency', currency: 'USD' }} />`
},
{
name: 'Pinned to en-US',
code: `<NumberField defaultValue={1000} locale="en-US" format={{ style: 'currency', currency: 'USD' }} />`
},
{
name: 'Pinned to de-DE',
code: `<NumberField defaultValue={1000} locale="de-DE" format={{ style: 'currency', currency: 'EUR' }} />`
}
]
};
4 changes: 3 additions & 1 deletion apps/www/src/content/docs/components/number-field/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ Full control with scrub area for drag-to-adjust interaction.

### Formatted

Number field with currency formatting.
Number field with currency formatting, powered by `Intl.NumberFormat` internally.

`format` sets what to format (currency, decimals); `locale` sets how it's written. Pin `locale` when the output should be stable across different users.

<Demo data={formatDemo} />

Expand Down
9 changes: 9 additions & 0 deletions apps/www/src/content/docs/components/number-field/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export interface NumberFieldProps {
*/
required?: boolean;

/**
* BCP 47 locale tag (or array). Controls separators, grouping, and currency
* symbol placement when used with `format`. Defaults to the user's runtime locale,
* which means rendered output varies by browser. Pass an explicit value when
* deterministic formatting is required.
* @defaultValue runtime locale
*/
locale?: Intl.LocalesArgument;

/** Number formatting options (Intl.NumberFormatOptions). */
format?: Intl.NumberFormatOptions;

Expand Down
Loading