Counter
Interactive counter component with animated number display and increment/decrement buttons. Perfect for React applications requiring numeric input controls with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/counter.json
npx shadcn@latest add https://www.shadcn.io/registry/counter.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/counter.json
bunx shadcn@latest add https://www.shadcn.io/registry/counter.json
Features
- Animated number display using the SlidingNumber component for smooth digit transitions
- Interactive buttons with hover and tap animations using Motion for engaging feedback
- Customizable styling with flexible button and number display configuration options
- Layout animations with automatic resizing and smooth transitions between states
- TypeScript support with complete interface definitions and prop validation
- shadcn/ui integration using Button components and consistent design patterns
Use Cases
This free open source React component works well for:
- Quantity selectors - Product quantity controls in e-commerce built with Next.js
- Settings panels - Numeric configuration options using TypeScript and Tailwind CSS
- Form inputs - Stepper inputs for numeric values with validation
- Gaming interfaces - Score counters and game statistics with animated updates
API Reference
Counter
Prop | Type | Default | Description |
---|---|---|---|
number | number | required | Current counter value to display |
setNumber | (number: number) => void | required | Function to update the counter value |
slidingNumberProps | Omit<SlidingNumberProps, 'number'> | - | Props passed to the SlidingNumber component |
buttonProps | Omit<React.ComponentProps<typeof Button>, 'onClick'> | - | Props passed to both increment and decrement buttons |
transition | Transition | {type: 'spring', bounce: 0, stiffness: 300, damping: 30} | Motion transition configuration for layout animations |
Button Styling
The component uses shadcn/ui Button components with default styling:
- Background: White (light mode) / Neutral-950 (dark mode)
- Hover effects: Reduced opacity with smooth transitions
- Size: Icon size with centered +/- symbols
- Animations: Scale effects on hover (1.05x) and tap (0.95x)
Implementation Notes
- Uses controlled state pattern requiring external state management
- Integrates SlidingNumber component for smooth digit transitions
- Motion animations provide tactile feedback on button interactions
- Layout prop enables automatic container resizing animations
- Compatible with shadcn/ui theming and design tokens
- Optimized for accessibility with proper button semantics
Apple Hello Effect
Handwriting animation component for React and Next.js applications. Built with Motion, TypeScript support, and Tailwind CSS styling featuring Apple-inspired text animations with multilingual support and customizable timing.
Glimpse
URL preview hover component for React and Next.js applications. Built with TypeScript support, Tailwind CSS styling, and shadcn/ui design featuring server-side data fetching, smooth transitions, and mobile accessibility.