About this set
Profile photo uploaders with a round preview and sensible checks. Profile photo with actions sets a 96 pixel avatar with a camera badge beside the person’s name, an Upload new photo button, a Remove button that only appears once there is a photo, and the rules underneath. Click the avatar to change it makes the 128 pixel circle itself the button: the file input is laid over it, so clicking, pressing Enter or dropping an image on it all work, and a dark Change photo overlay appears on hover and keyboard focus. Workspace logo with size previews uses a rounded square for a team or company logo and shows the chosen image at 40, 28 and 20 pixels, the sizes it will appear at in a sidebar or a tab. Each avatar falls back to initials or a plus sign when empty. The script checks the file type, the file size and, by loading the image first, its pixel size, and it explains exactly what is wrong, for example that a photo is 320 by 240 pixels when 400 by 400 is needed. The preview uses URL.createObjectURL, and the input always holds exactly the image on screen.
What’s included
- Round preview over an initials fallback
- Remove button that appears only when a photo is set
- Click or drop on the avatar with a Change photo overlay
- Logo previews at 40, 28 and 20 pixels
- Minimum pixel size check as well as type and file size
Accessibility
Every input has a label, visible or visually hidden, and is described by the hint and the error message. The visible button or avatar shows a focus ring when the input has keyboard focus, and the overlay appears on focus as well as hover. Remove returns focus to the upload control, and new, rejected and removed images are announced in a polite live region. The overlay fade switches off under prefers-reduced-motion.
Customise it
Change --av-size, --av-accent and the initials gradient on .av, and the limits with accept, data-max-size and data-min-px on the input. Bootstrap uses .rounded-circle, .btn-primary and .btn-outline-danger; Tailwind sets sizes with size-24 and size-32 and colours in @theme.






