Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Currency Input

    Money field that formats as you type (Rp 12.500.000), keeps the caret in place, and posts the plain number. Optional quick amount chips.

    Current balance Rp 245.000
    Rp

    Minimum Rp10.000, maximum Rp10.000.000

    Current balanceRp 245.000
    Rp

    Minimum Rp10.000, maximum Rp10.000.000

    Current balanceRp 245.000
    Rp

    Minimum Rp10.000, maximum Rp10.000.000

    Current balance Rp 245.000
    Rp

    Minimum Rp10.000, maximum Rp10.000.000

    Current balanceRp 245.000
    Rp

    Minimum Rp10.000, maximum Rp10.000.000

    @php
        $panel = 'grid gap-4 rounded-xl border border-line bg-surface p-5';
        $balance = 'flex items-baseline justify-between';
        $balanceLabel = 'text-sm text-muted';
        $balanceValue = 'text-lg font-semibold text-ink tabular-nums';
    @endphp
    
    <div class="{{ $panel }}">
        <div class="{{ $balance }}">
            <span class="{{ $balanceLabel }}">Current balance</span>
            <span class="{{ $balanceValue }}">Rp 245.000</span>
        </div>
        <x-markas.currency-input
            label="Top-up amount"
            name="amount"
            hint="Minimum Rp10.000, maximum Rp10.000.000"
            :min="10000"
            :max="10000000"
            :value="100000"
            :presets="[50000, 100000, 250000, 500000, 1000000]"
        />
        <x-markas.button>Top up balance</x-markas.button>
    </div>
    import { Button } from "@/components/markas/Button";
    import { CurrencyInput } from "@/components/markas/CurrencyInput";
    
    const panel = "grid gap-4 rounded-xl border border-line bg-surface p-5";
    const balance = "flex items-baseline justify-between";
    const balanceLabel = "text-sm text-muted";
    const balanceValue = "text-lg font-semibold text-ink tabular-nums";
    
    export default function CurrencyInputExample() {
      return (
        <div className={panel}>
          <div className={balance}>
            <span className={balanceLabel}>Current balance</span>
            <span className={balanceValue}>Rp 245.000</span>
          </div>
          <CurrencyInput
            label="Top-up amount"
            name="amount"
            hint="Minimum Rp10.000, maximum Rp10.000.000"
            min={10000}
            max={10000000}
            defaultValue={100000}
            presets={[50000, 100000, 250000, 500000, 1000000]}
          />
          <Button>Top up balance</Button>
        </div>
      );
    }
    <script setup lang="ts">
    import { ref } from "vue";
    import Button from "@/components/markas/Button.vue";
    import CurrencyInput from "@/components/markas/CurrencyInput.vue";
    
    const panel = "grid gap-4 rounded-xl border border-line bg-surface p-5";
    const balance = "flex items-baseline justify-between";
    const balanceLabel = "text-sm text-muted";
    const balanceValue = "text-lg font-semibold text-ink tabular-nums";
    
    const amount = ref<number | null>(100000);
    </script>
    
    <template>
      <div :class="panel">
        <div :class="balance">
          <span :class="balanceLabel">Current balance</span>
          <span :class="balanceValue">Rp 245.000</span>
        </div>
        <CurrencyInput
          v-model="amount"
          label="Top-up amount"
          name="amount"
          hint="Minimum Rp10.000, maximum Rp10.000.000"
          :min="10000"
          :max="10000000"
          :presets="[50000, 100000, 250000, 500000, 1000000]"
        />
        <Button>Top up balance</Button>
      </div>
    </template>
    <script lang="ts">
      import Button from "$lib/components/markas/Button.svelte";
      import CurrencyInput from "$lib/components/markas/CurrencyInput.svelte";
    
      const panel = "grid gap-4 rounded-xl border border-line bg-surface p-5";
      const balance = "flex items-baseline justify-between";
      const balanceLabel = "text-sm text-muted";
      const balanceValue = "text-lg font-semibold text-ink tabular-nums";
    </script>
    
    <div class={panel}>
      <div class={balance}>
        <span class={balanceLabel}>Current balance</span>
        <span class={balanceValue}>Rp 245.000</span>
      </div>
      <CurrencyInput
        label="Top-up amount"
        name="amount"
        hint="Minimum Rp10.000, maximum Rp10.000.000"
        min={10000}
        max={10000000}
        defaultValue={100000}
        presets={[50000, 100000, 250000, 500000, 1000000]}
      />
      <Button>Top up balance</Button>
    </div>
    ---
    import Button from "@/components/markas/Button.astro";
    import CurrencyInput from "@/components/markas/CurrencyInput.astro";
    
    const panel = "grid gap-4 rounded-xl border border-line bg-surface p-5";
    const balance = "flex items-baseline justify-between";
    const balanceLabel = "text-sm text-muted";
    const balanceValue = "text-lg font-semibold text-ink tabular-nums";
    ---
    
    <div class={panel}>
      <div class={balance}>
        <span class={balanceLabel}>Current balance</span>
        <span class={balanceValue}>Rp 245.000</span>
      </div>
      <CurrencyInput
        label="Top-up amount"
        name="amount"
        hint="Minimum Rp10.000, maximum Rp10.000.000"
        min={10000}
        max={10000000}
        defaultValue={100000}
        presets={[50000, 100000, 250000, 500000, 1000000]}
      />
      <Button>Top up balance</Button>
    </div>
    import { Component } from "@angular/core";
    import { Button } from "./markas/button.component";
    import { CurrencyInput } from "./markas/currency-input.component";
    
    @Component({
      selector: "markas-example",
      imports: [Button, CurrencyInput],
      template: `
        <div [class]="panel">
          <div [class]="balance">
            <span [class]="balanceLabel">Current balance</span>
            <span [class]="balanceValue">Rp 245.000</span>
          </div>
          <markas-currency-input
            label="Top-up amount"
            name="amount"
            hint="Minimum Rp10.000, maximum Rp10.000.000"
            [min]="10000"
            [max]="10000000"
            [defaultValue]="100000"
            [presets]="presets"
          />
          <button markas-button>Top up balance</button>
        </div>
      `,
    })
    export default class CurrencyInputExample {
      protected readonly panel =
        "grid gap-4 rounded-xl border border-line bg-surface p-5";
      protected readonly balance = "flex items-baseline justify-between";
      protected readonly balanceLabel = "text-sm text-muted";
      protected readonly balanceValue =
        "text-lg font-semibold text-ink tabular-nums";
      protected readonly presets = [50000, 100000, 250000, 500000, 1000000];
    }

    Examples

    US dollars

    $

    Billed in US dollars at the end of each month

    $

    Billed in US dollars at the end of each month

    $

    Billed in US dollars at the end of each month

    $

    Billed in US dollars at the end of each month

    $

    Billed in US dollars at the end of each month

    States

    Rp

    Amount exceeds your daily limit of Rp5.000.000

    Rp
    Rp
    Rp

    Amount exceeds your daily limit of Rp5.000.000

    Rp
    Rp
    Rp

    Amount exceeds your daily limit of Rp5.000.000

    Rp
    Rp
    Rp

    Amount exceeds your daily limit of Rp5.000.000

    Rp
    Rp
    Rp

    Amount exceeds your daily limit of Rp5.000.000

    Rp
    Rp

    Donation with suggested amounts

    Support the village library

    Every rupiah goes to new books for 300 students.

    Rp

    Minimum Rp5.000

    Support the village library

    Every rupiah goes to new books for 300 students.

    Rp

    Minimum Rp5.000

    Support the village library

    Every rupiah goes to new books for 300 students.

    Rp

    Minimum Rp5.000

    Support the village library

    Every rupiah goes to new books for 300 students.

    Rp

    Minimum Rp5.000

    Support the village library

    Every rupiah goes to new books for 300 students.

    Rp

    Minimum Rp5.000

    Installation

    npx markasui@latest add currency-input

    Usage

    <x-markas.currency-input
        label="Top-up amount"
        name="amount"
        hint="Minimum Rp10.000"
        :min="10000"
        :value="old('amount', 100000)"
        :presets="[50000, 100000, 250000, 500000]"
    />

    Needs Alpine.js. The form receives amount=100000, a plain number without separators.

    Livewire

    <x-markas.currency-input label="Amount" wire:model.live.debounce.400ms="amount" :presets="[50000, 100000]" />

    wire:model binds the plain number (for example 12500000), not the formatted text. Server changes reformat the field. Preset chips update the property as well.

    import { CurrencyInput } from "@/components/markas/CurrencyInput";
    
    <CurrencyInput
      label="Top-up amount"
      name="amount"
      hint="Minimum Rp10.000"
      min={10000}
      defaultValue={100000}
      presets={[50000, 100000, 250000, 500000]}
      onValueChange={setAmount}
    />;
    <script setup lang="ts">
    import { ref } from "vue";
    import CurrencyInput from "@/components/markas/CurrencyInput.vue";
    
    const amount = ref<number | null>(100000);
    </script>
    
    <template>
      <CurrencyInput
        v-model="amount"
        label="Top-up amount"
        name="amount"
        hint="Minimum Rp10.000"
        :min="10000"
        :presets="[50000, 100000, 250000, 500000]"
      />
    </template>
    <script lang="ts">
      import CurrencyInput from "$lib/components/markas/CurrencyInput.svelte";
    
      let amount = $state<number | null>(100000);
    </script>
    
    <CurrencyInput
      label="Top-up amount"
      name="amount"
      hint="Minimum Rp10.000"
      min={10000}
      bind:value={amount}
      presets={[50000, 100000, 250000, 500000]}
    />
    ---
    import CurrencyInput from "@/components/markas/CurrencyInput.astro";
    ---
    
    <CurrencyInput
      label="Top-up amount"
      name="amount"
      hint="Minimum Rp10.000"
      min={10000}
      defaultValue={100000}
      presets={[50000, 100000, 250000, 500000]}
    />

    A small custom element formats while typing and fills the hidden input. It dispatches a bubbling markas-change event with the amount (or null) as detail.

    import { Component, signal } from "@angular/core";
    import { CurrencyInput } from "./markas/currency-input.component";
    
    @Component({
      selector: "app-top-up",
      imports: [CurrencyInput],
      template: `
        <markas-currency-input
          label="Top-up amount"
          name="amount"
          hint="Minimum Rp10.000"
          [min]="10000"
          [(value)]="amount"
          [presets]="presets"
        />
      `,
    })
    export class TopUp {
      amount = signal<number | null>(100000);
      presets = [50000, 100000, 250000, 500000];
    }

    id, name, placeholder, aria-label, and class land on the visible field.

    • IDR is the default: Rp prefix, dot thousands (12.500.000), no decimals. currency="USD" switches to $, comma thousands, and up to two decimals (1,250.50).
    • Separators are added while typing and the caret stays next to the digit you typed. Backspace or Delete beside a separator removes the neighbouring digit.
    • The visible field has no name. Pass name to render a hidden input with the plain number, ready for a regular form post.
    • min and max clamp the amount on blur and when a chip is picked. Validate on the server too.
    • Chips count the digits to the new amount in 400ms. With reduced motion the amount changes instantly.
    • Attributes and class go to the visible field.

    Props

    NameTypeDefaultDescription
    labelstring-Label text, linked to the field through for and id.
    hintstring-Hint below the field. Hidden while an error is shown.
    errorstring-Error message. Turns on aria-invalid and the danger border.
    currency'IDR' | 'USD'IDRIDR shows Rp with dot thousands and no decimals. USD shows $ with comma thousands and up to two decimals.
    minnumber-Lowest value. The amount is clamped on blur and when a chip is picked.
    maxnumber-Highest value. The amount is clamped on blur and when a chip is picked.
    value / defaultValue / v-modelnumber | nullnullStarting amount. Blade uses value, React uses defaultValue with onValueChange, Vue uses v-model.
    namestring-Name of a hidden input that submits the plain number, for example 12500000. The visible field has no name.
    presetsnumber[][]Quick amount chips shown below the field, labelled short (50rb, 1jt, $1K). Picking one counts the digits to the new amount.
    presetsLabelstringQuick amountsAccessible name of the chip group.
    idstringautoId of the visible field. Generated automatically when empty.
    bind:value / [(value)]number | null-Svelte and Angular. Two-way binding of the amount. Svelte also takes onValueChange; Angular emits valueChange.
    markas-changeCustomEvent<number | null>-Astro only. Bubbling event with the new amount as detail.

    Accessibility

    • The label is linked to the field, and the currency symbol, hint, and error are read through aria-describedby.
    • The field uses inputmode numeric or decimal so phones show a number keypad.
    • Chips are toggle buttons in a labelled group; the chip that matches the amount has aria-pressed true.
    • With reduced motion picking a chip sets the amount instantly instead of counting.

    Related components

    More markasui components with the same classes in every framework.