Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useCounter

A number with increment, decrement, set and reset actions.

HooksState@gaudi/design-system/hooks/state/use-counterView in StorybookSource

Functional updates compose within one event. Reset returns to the current initialValue argument. The hook imposes no product-specific bounds.

Usage

import { useCounter } from '@gaudi/design-system/hooks';
const { count, increment, decrement, reset } = useCounter(1);

Examples

Playground

Storybook

API

1 option
2 return values

Accessibility

Give increment and decrement buttons meaningful names; announce changes only when useful.