Skip to content
BigBang

Popular

    ↑↓Navigate↵OpenEscClose
    TR

    Components

    AmountInput

    An amount of money typed in the Provider language and reported in exact minor units, never a float.

    Storybook
    Storybook
    Source
    Source

    The example below loads live from Storybook; open it there to use the controls.

    Live example, StorybookOpen in Storybook

    The currency sits inside the box, after the number in Turkish. On leaving the field the amount is formatted as 1,234.50.

    Separate the fraction with a decimal point.

    import { AmountInput, Provider } from '@bigbang/ui';
    export default function Default() {
    return (
    <Provider locale="en-GB">
    <AmountInput label="Amount" description="Separate the fraction with a decimal point." placeholder="0.00" className="max-w-xs" />
    </Provider>
    );
    }

    min and max are in minor units; outside them the field shows its own message. onValueChange gives a bigint.

    At least ₺10.00, at most ₺50,000.00.

    150000n
    import { AmountInput, Provider } from '@bigbang/ui';
    import { useState } from 'react';
    export default function Limits() {
    const [value, setValue] = useState<bigint | null>(150000n);
    return (
    <Provider locale="en-GB">
    <div className="flex max-w-xs flex-col gap-md">
    <AmountInput label="Amount" description="At least ₺10.00, at most ₺50,000.00." value={value} onValueChange={setValue} min={1000n} max={5000000n} name="amount" />
    <code className="type-body-sm text-fg-subtle">{value === null ? 'null' : `${value}n`}</code>
    </div>
    </Provider>
    );
    }

    The box uses the same tokens as TextInput.

    Separate the fraction with a decimal point.

    Separate the fraction with a decimal point.

    import { AmountInput, Provider } from '@bigbang/ui';
    export default function Default() {
    return (
    <Provider locale="en-GB">
    <AmountInput label="Amount" description="Separate the fraction with a decimal point." placeholder="0.00" className="max-w-xs" />
    </Provider>
    );
    }