@m3000/marketv0.0.0

Price Input

Composable stepped price input for bigint-backed values, dynamic tick sizes, and custom price rendering.

Installation

pnpm add @m3000/market

Usage

$1,250

PriceInput is the recommended API for price entry. It wraps the lower-level SteppedInput primitive with sensible decimal behavior for smallest-unit values like cents or wei, while preserving the same composable controls.

Examples

Price Input

Use PriceInput when your source of truth is stored in the smallest unit, such as cents or wei.

$1,250

Price Rendering

Use PriceInput.Value when you want the input to display a fully formatted price, while keeping the control in charge of stepping and dragging.

1.8250ETH

Dynamic Tick Sizes

Provide getTickSize as a function of the current value when the allowed bid increment changes across price bands.

Step size shifts from $10 to $25 to $50 as the value increases.

$950

Snap To Tick

Set snapToTick to keep typed or dragged prices aligned to the valid tick grid using "up", "down", or "nearest" behavior.

Starting from $10.50 with a $10.00 tick size, each mode snaps edits to a different valid price level.

snapToTick="up"

$10.5

snapToTick="down"

$10.5

snapToTick="nearest"

$10.5

Raw Numeric Input

If you need the lower-level primitive without the price-focused wrapper, the plain editable SteppedInput is still available.

API Reference

SteppedInput.Root

The controlled root that owns the current price value, valid range, decimal scaling, and stepping rules.

PropTypeDefaultDescription
valuebigintrequiredCurrent raw price value
onChange(value: bigint) => voidrequiredCalled with the next raw price value
minbigintnoneMinimum allowed raw value
maxbigintnoneMaximum allowed raw value
getTickSize(currentValue: bigint) => bigintrequiredReturns the valid price increment for the current raw value
decimalsnumber0Scales bigint price values for editing as decimal numbers
disabledbooleanfalseDisables all controls and interactions
classNamestringnoneAdditional classes for the root
childrenReactNoderequiredCompound children rendered inside the number field
snapToTick"up" | "down" | "nearest" | falsefalseSnaps changes to the current tick grid

SteppedInput.Group

Wraps the controls for the decrement button, scrub area, and increment button.

PropTypeDefaultDescription
childrenReactNoderequiredThe grouped stepped input controls
classNamestringnoneAdditional classes for the group

SteppedInput.Decrement

Button that decreases the current value by the active tick size.

PropTypeDefaultDescription
childrenReactNode"-"Button content
classNamestringnoneAdditional classes for the decrement button

SteppedInput.Increment

Button that increases the current value by the active tick size.

PropTypeDefaultDescription
childrenReactNode"+"Button content
classNamestringnoneAdditional classes for the increment button

SteppedInput.ScrubArea

Interactive region that supports dragging and contains either SteppedInput.Input or SteppedInput.Value.

PropTypeDefaultDescription
childrenReactNoderequiredScrubbable content
classNamestringnoneAdditional classes for the scrub area

SteppedInput.ScrubAreaCursor

Optional drag handle rendered inside SteppedInput.ScrubArea. This is the right place for a cursor icon or short hint text.

SteppedInput.Input

Editable input element styled for the default price-entry presentation.

PropTypeDefaultDescription
classNamestringnoneAdditional classes for the input

SteppedInput.Value

Custom value renderer for cases where the display should follow your own price formatting, including Price-style output for smallest-unit values.

PropTypeDefaultDescription
children({ value, inputValue, step, disabled }) => ReactNoderequiredRender function receiving the raw value plus current editable input state
classNamestringnoneAdditional classes for the value container

On this page