ExpoStartup

Counter

A numeric input component with increment and decrement buttons

Counter

A component for incrementing and decrementing numeric values with a clean interface.

Import

import Counter from '@/components/forms/Counter';

Props

PropTypeDefaultDescription
labelstringRequiredThe label displayed next to the counter
valuenumberundefinedThe controlled value of the counter
onChange(value: number | undefined) => voidCalled when the value changes
minnumber0Minimum allowed value
maxnumber99Maximum allowed value
classNamestringAdditional class names for the container
styleViewStyleCustom styles for the container

Basic Usage

<Counter
  label="Quantity"
  onChange={(value) => console.log('New value:', value)}
/>

Controlled Component

const [quantity, setQuantity] = useState(1);
 
<Counter
  label="Quantity"
  value={quantity}
  onChange={setQuantity}
/>

With Min/Max Limits

<Counter
  label="Number of guests"
  min={1}
  max={10}
  onChange={setGuests}
/>

On this page