Avatar uploadPro
Click or drop a photo onto the avatar to crop it in place with drag, wheel zoom and keys, then upload through a progress ring with clear errors and Retry.
oxyn add avatar-uploadThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Click or drop a photo onto the avatar to crop it in place.
- The file is checked (type, then size) before it is read; its size comes from the PNG / GIF / JPEG / WebP header (image_size) and it shows as a data URL.
- The avatar grows from size_px (88) into a 184 px crop circle on a tinted stage.
- Drag moves the photo one to one; past an edge it follows at a falling rate, never more than a quarter of the circle (Crop::shown), and springs back inside on release.
When not to use
- On or off for things that apply right away: use Switch instead.
- A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself: use Checkbox instead.
- Pick one: use Radio group instead.
Installation
Avatar upload is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add avatar-uploadUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Cropping
The crop circle: drag, wheel, slider, arrows, + / −, 0, Enter, Escape.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Photo
At rest with a photo: Replace or Remove.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Failed
Save to see the progress ring stop and Retry.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Empty
No photo yet: initials.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
AvatarUpload
| Prop | Type | Default | Description |
|---|---|---|---|
label | String | "Profile photo" | Heading beside the avatar. |
hint | Option<String> | Default::default() | Helper copy (defaults to the accepted types and size limit). |
src | Option<String> | Default::default() | Current photo (URL or data URL). |
initials | String | "AK" | Initials when there is no photo. |
accept | Vec<String> | vec!["image/png".to_string(), "image/jpeg".to_string(), "image/webp".to_string()] | Accepted MIME types. |
max_size | u64 | 5_242_880 | Largest file in bytes. |
size_px | f32 | 88.0 | Avatar diameter at rest. |
fail_first | bool | Default::default() | The first upload attempt fails (demos the error and Retry). |
start_cropping | bool | Default::default() | Open the cropper on mount with `src` (demos the crop state). |
removable | bool | true | Show Remove. |
disabled | bool | Default::default() | Disabled. |
nowrequired | ClockMs | — | Shared clock (the progress ring). |
on_upload | EventHandler<(f32, f32, f32)> | — | Saved: the crop square as (centre x, centre y, side) fractions of the image. |
on_remove | EventHandler<()> | — | Removed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Avatar, Upload / Replace, Remove; while cropping the crop area, zoom, Save, Cancel |
| Arrows | Move 2 % (Shift 10 %) |
| or− | Zoom |
| 0 | Reset |
| Enter | Save and upload |
| Escape | Cancel |
Accessibility
- The crop area is a focusable application region with its keys in its label.
- Errors are role=alert.
From the spec
- The crop area is a focusable region with its keys in its label; errors are role=alert.
Motion & interaction
Timing
- Grow 450 ms (cubic-bezier .25,1,.4,1); spring back 350 ms; done check pops 300 ms.
- Reduced motion swaps sizes and positions without travel.
Responsive behaviour
- The crop circle is 184 px; the row wraps on narrow screens.
Edge cases (spec)
- The crop circle is fixed at 184 px.
Notes for AI
- Import
AvatarUploadfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
AvatarUploadElinoxyn_gpui. - Props to set first:
now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.