Installation
Usage
Props
Initial team size (1-4)
Callback function triggered when team size changes. Receives the new size as parameter.
Additional CSS classes to apply to the container
Features
- Avatar Stack: Visual representation with overlapping avatars
- Smooth Animations: Spring-based transitions for avatar appearance/disappearance
- Counter Animation: Sliding number animation with directional awareness
- Vibration Feedback: Shake animation when trying to exceed limits
- Limit Enforcement: Prevents going below 1 or above 4 team members
- Keyboard Accessible: Full keyboard support for increment/decrement
- Dark Mode: Fully styled for both light and dark themes
Constants
Animation Variants
Container Animation
Avatar Animation
Vibration Animation
Counter Animation
The counter uses direction-aware animations:- Increment: New number slides up from bottom
- Decrement: New number slides down from top
Example with Handler
Team Member Data
The component uses predefined avatar URLs:Styling Details
Card Container
- White background with subtle shadow
- Rounded corners (
rounded-2xl) - Border with low opacity
- Dark mode: Semi-transparent zinc background
Avatars
- 48px × 48px (size-12)
- Rounded full circle
- White border with shadow
- -10px left margin for overlap (except first)
- Z-index stacking (decreasing order)
Buttons
- 36px × 36px (h-9 w-9)
- Gradient background (white → zinc-50)
- Border with shadow
- Hover effects: darker border, increased shadow
- Disabled state: reduced opacity, no pointer
Counter Display
- Large text (text-3xl)
- Gradient text (zinc-800 → zinc-500)
- Bold weight
- Small label below (“member” / “members”)
Accessibility
- Semantic
<fieldset>and<legend>elements <output>element for counter with ARIA label- Descriptive
aria-labelon buttons - Keyboard support (Enter and Space keys)
- Disabled state prevents invalid actions
- Screen reader announces current team size
State Management
Internal states:peopleCount: Current team sizeisVibrating: Vibration animation triggerdirectionRef: Tracks increment/decrement for animation direction
Dependencies
motion(Framer Motion with Variants type)next/imagereact(useState, useRef hooks)