FSAI Design System
Components

Quantity Input

Composite amount-plus-unit input used for menu quantities and ingredient measurements.

Overview

QuantityInput is a composite field for entering:

  • a numeric amount
  • a menu unit

It combines InputPrimitive and Picker into a single compact control.

This component is specifically shaped around MenuUnit and MENU_UNITS from @fsai/sdk. It is best treated as a menu-domain component, not a generic amount-plus-unit field.

Basic Usage

<QuantityInput
  amount={quantity}
  unit={unit}
  onChangeAmount={setQuantity}
  onChangeUnit={setUnit}
/>

With react-hook-form

QuantityInput commonly uses two controllers: one for the numeric amount and one for the unit.

<QuantityInput
  amount={quantityField.value}
  onBlur={quantityField.onBlur}
  onChangeAmount={quantityField.onChange}
  onChangeUnit={unitField.onChange}
  unit={unitField.value}
  error={quantityState.error?.message || unitState.error?.message}
/>

This is the production pattern used in IngredientsFieldArray.tsx.

Props

PropTypeDefaultDescription
amountnumber | nullCurrent numeric amount.
unitMenuUnitRequired selected unit.
onChangeAmount(amount: number | null) => voidRequired amount change handler.
onChangeUnit(unit: MenuUnit) => voidRequired unit change handler.
onBlur() => voidBlur handler for form integration.
errorstringInline field error text.
labelstringOptional label.
idstringInput id.
disabledbooleanDisables both amount and unit interactions.

Important Behavior

  • an empty numeric input becomes null, not 0
  • unit selection is driven by MENU_UNITS
  • the unit picker is embedded inside the same visual field

Brand Dashboard Usage

PatternPathNotes
Menu ingredient field arrayfsai/apps/brand-dashboard/src/modules/menu/components/IngredientsFieldArray/IngredientsFieldArray.tsxDual-controller form integration with merged error handling.
Local-state ingredient usagefsai/apps/brand-dashboard/src/modules/menu/components/IngredientPanel/IngredientPanelUsedIn/IngredientPanelUsedIn.tsxSame component used outside RHF with local state and blur handling.

Guidelines

  • Do use QuantityInput for menu-domain quantity-plus-unit entry
  • Do wire amount and unit separately in form state
  • Do merge amount and unit validation into one visible error when needed
  • Don't treat it as a fully generic unit-entry system outside the menu domain without checking whether the menu-unit assumptions still fit

On this page