Avatar Gender Toggle
An expressive illustrated character pill switch that smoothly morphs between Female and Male personas with spring physics, idle micro-animations, and vertical-wipe labels.
Features
- Topology-matched cubic Bezier paths that morph hair bangs and round-to-wayfarer eyewear frames seamlessly.
- Vertical spring-animated face travel inside a cylindrical 3D-shaded pill track.
- Signature idle micro-animations: diagonal specular lens glint in Female state and natural eye blink in Male state.
- Interactive vertical-wipe
Female/Maleradio labels with full dark/light mode support andprefers-reduced-motionaccessibility.
Use cases
- Onboarding flows, character creators, and profile preference forms.
- Playful binary persona or theme switches that benefit from tactile, illustrative feedback.
Installation
pnpm dlx shadcn@latest add @abushaidislam/avatar-gender-toggle
Usage
import { AvatarGenderToggle } from "@/components/avatar-gender-toggle"export default function ProfileGenderPicker() {
return (
<div className="flex min-h-95 items-center justify-center p-8">
<AvatarGenderToggle defaultValue="female" size="md" />
</div>
)
}API reference
AvatarGenderToggle
Prop
Type
Accessibility
- Exposes
role="radiogroup"on the root container,role="switch"on the illustrated pill button, androle="radio"on the interactive labels. - Supports
ArrowUp/ArrowLeft,ArrowDown/ArrowRight,Space, andEnterkeyboard navigation. - Respects
prefers-reduced-motionby disabling idle animations and snapping transitions immediately.
License and usage
- Free to use and modify in both personal and commercial projects.
- Attribution is appreciated but not required.
- Released under the MIT License.
Every component here is built and maintained by one person. If you enjoy using them, you can sponsor my work.