PNG, JPG or GIF, up to 4 MB. Drop an image on the circle too.
Installation
$ pnpm dlx shadcn@latest add @synccn/avatar-uploadFirst time in this project? Connect synccn with one command.
Usage
import { AvatarUpload } from "@/components/ui/avatar-upload";<AvatarUpload name="Michael" onChange={setFile} />API reference
Generated from the component's TypeScript types, so it always matches the code.
AvatarUpload
Round avatar picker: click or drop an image to preview it; remove to go back to initials.
PropTypeDescription
- name
stringDefault
""Used for initials before a photo is chosen.
- size
numberDefault
96Avatar diameter in pixels.
- maxSize
numberDefault
4 * 1048576Largest file allowed, in bytes.
- onChange
(file: File | null) => voidCalled with the chosen file, or null when removed.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Camera, Trash2
Accessibility
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA attributes: aria-label
- Shows a visible focus ring for keyboard users
- Includes text only screen readers hear
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.Radio GroupPick one option, shown as dots or as selectable cards.