AI profile photo
Shown as Likeness, a made-up product
A profile-photo field with an assistant that centres the face, calms the background and fixes the light before anything is saved, with variations, a before and after divider, and a live preview of where the photo appears.
Installation
pnpm dlx shadcn@latest add "https://propui.dev/r/likeness-photo.json?token=…"Adds the piece to components/propui/07-likeness-photo/ and installs motion. Needs a free account: sign in and the command includes your token. Fonts load from Prop UI; download the zip to self-host them.
When to use
Reach for it when
- The profile-photo field in account or workspace settings, where the photo must meet a directory policy.
- An upload that an assistant checks and tidies before anything is saved, with the changes shown and explained.
- Any avatar setting that should preview where the photo appears and who can see it.
Something else fits when
- Uploading documents or many files at once: File upload handles a queue of files.
- Signing in or creating an account: Sign-up and Passkey login cover those.
Usage
Fills a full window: give it a container with a definite height.
import Piece from "@/components/propui/07-likeness-photo/Section";
export default function Page() {
return (
<main className="h-dvh w-full overflow-hidden">
<Piece />
</main>
);
}Change PERSON, the upload limits, the checks and the variations in data.ts, and put your own sample photos in photos/. Replace the simulated upload and assistant pass in Section.tsx with your upload and image calls, and save in save().
Your data
Replace these and everything on screen follows.
PERSON{ name; first; initials; role; org; email }- The directory card, the initials and the saved message.
LIMIT_MB, TYPES, TYPE_LABELnumber, string[], string- What uploads are accepted and the reason given when one isn't.
SAMPLES{ id; label; file; size; img; face: { x; top; eye; chin }; light }[]- The sample photos, where each face sits, and the lighting fix applied to it.
CHECKS, CHECKS_OWN{ id; label; done; why }[]- The assistant's checklist for samples and for your own files, and the Why these changes? lines.
SUGGESTIONS{ id; label; why }[]- The variation chips: Auto-crop and three backdrops.
MONO{ id; label; bg; fg }[]- The colours offered for initials.
AUDIENCE, LAST_CHANGE{ id; label }[], string- Who can see it, and the audit line in the footer.
Interactions
- Click the avatar or Upload photo, drop an image anywhere on the card, or paste one from the clipboard.
- Start from one of three sample photos without a file.
- Watch the checklist tick: each tick changes the avatar as it lands (face centred, background softened, lighting balanced, cropped to 512 px).
- Hover or focus a variation to preview it on the avatar, click to apply it, and click again to undo it.
- Compare with original: drag the before and after divider across the avatar.
- Open Why these changes? for one line on each edit; the policy line says whether the result meets the directory rules.
- Choose who can see it, then Save photo with Undo, or Discard.
- Use initials in a palette colour instead of a photo, or remove the photo.
- Open Try a state for an oversized file, a wrong file type, a dropped connection on the next upload, or to start over.
Keyboard
- ←or→
- Move the before and after divider by 5%.
- HomeorEnd
- Move the divider to either edge.
- ⌘V
- Paste an image to upload it.
- Esc
- Close the Try a state menu.
Behaviour
Read from the code: roles, motion, breakpoints and what runs.
Accessibility
- The card is a section labelled by its heading, and the avatar is a button named Change profile photo.
- The before and after divider is a slider with its value spoken as a percentage of the original.
- Variations are toggle buttons with aria-pressed; the initials colours and the audience choice are radio groups.
- Upload progress and the assistant's work are announced through a polite live region; upload errors are alerts.
- The collapsed Why these changes? panel and the hidden Save and Discard buttons are inert until they show.
- Saving and undoing are announced in the footer.
Motion
- A ring around the avatar fills with the upload, and a scan line passes over it while the assistant works.
- Checks pop in with a spring; the photo's crop, backdrop and lighting ease between looks.
- Panels cross-fade in place, the audience pill slides between choices, and Why these changes? opens by height.
- Reduced motion stops the scan and the busy icon and swaps the transitions for instant changes.
Responsive
- Above 720px the avatar sits beside the assistant panel, and where it appears sits beside who can see it.
- Below 720px everything stacks in one column, the sample photos list one per row, and the footer wraps its buttons under the audit line.
Performance
- Timers run only during the simulated upload and the assistant pass.
- The edits are CSS transforms, filters and masks on one image: nothing is drawn to a canvas, and nothing is random.
- Three sample photos of about 1000 px, 100 to 160 KB each, imported statically. Inter in one variable file.
Notes for AI
Give your coding assistant the Markdown, not a screenshot.
- Keep every person, limit, check and variation in data.ts; the card reads them from there.
- Each sample needs its face box in data.ts, or the crop will miss the face.
- Light and dark: keep colours in the tokens at the top of post.css.
/p/likeness-photo/markdownThe whole library for assistants: llms.txt, or the MCP server in AI tools and MCP.