📄 primereact/hooks/usecounter

File: usecounter.md | Updated: 11/15/2025

Source: https://primereact.org/hooks/usecounter/

Introducing PrimeReact v11 Alpha 🥁Learn More

useCounter

Manages a counter state.

Import#


import { useCounter } from 'primereact/hooks';
         

Copy

Basic#


Simple counter with increment, decrement and reset functions.

0

<span className="font-bold text-4xl mb-5">{count}</span>
<div className="flex flex-wrap gap-3">
    <Button icon="pi pi-plus" className="p-button-outlined p-button-rounded p-button-success" onClick={increment}></Button>
    <Button icon="pi pi-minus" className="p-button-outlined p-button-rounded" onClick={decrement}></Button>
    <Button icon="pi pi-times" className="p-button-outlined p-button-rounded p-button-danger" onClick={reset}></Button>
</div>
         

Copy

Options#


Step factor to change the counter is specified using the step option. In addition boundaries can be defined with min and max options.

10

<span className="font-bold text-4xl mb-5">{count}</span>
<div className="flex flex-wrap gap-3">
    <Button icon="pi pi-plus" className="p-button-outlined p-button-rounded p-button-success" onClick={increment}></Button>
    <Button icon="pi pi-minus" className="p-button-outlined p-button-rounded" onClick={decrement}></Button>
    <Button icon="pi pi-times" className="p-button-outlined p-button-rounded p-button-danger" onClick={reset}></Button>
</div>
         

Copy

  • Import

  • Basic

  • Options

PrimeReact 10.9.7 by PrimeTek