Counter
A component for displaying numerical values with increment/decrement controls.
Installation
npm install @cleartrip/ct-design-counter
# or
pnpm add @cleartrip/ct-design-counter
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Counter } from '@cleartrip/ct-design-counter';
function Example() {
return (
<Counter>
{/* Basic usage */}
</Counter>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
onChange | (value: number, operation: CounterOperation) => void | — | ✅ Yes | Callback function triggered on counter value change. It provides the new |
minimumIntegerDigitsValue | number | — | No | The minimum number of integer digits to be displayed in the value — |
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Counter } from 'yagami/core/components';
+ import { Counter } from '@cleartrip/ct-design-counter';