Skip to content
Back

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-upload
The code is part of Oxyn Pro

The preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.

Get Pro

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.

Terminal
oxyn add avatar-upload

Usage

Dioxus · rust
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Examples

Cropping

The crop circle: drag, wheel, slider, arrows, + / −, 0, Enter, Escape.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Photo

At rest with a photo: Replace or Remove.

Profile photoPNG, JPG, WEBP up to 5.0 MB
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Failed

Save to see the progress ring stop and Retry.

Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Empty

No photo yet: initials.

AK
Profile photoPNG, JPG, WEBP up to 5.0 MB
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

API reference

AvatarUpload

PropTypeDefaultDescription
labelString"Profile photo"Heading beside the avatar.
hintOption<String>Default::default()Helper copy (defaults to the accepted types and size limit).
srcOption<String>Default::default()Current photo (URL or data URL).
initialsString"AK"Initials when there is no photo.
acceptVec<String>vec!["image/png".to_string(), "image/jpeg".to_string(), "image/webp".to_string()]Accepted MIME types.
max_sizeu645_242_880Largest file in bytes.
size_pxf3288.0Avatar diameter at rest.
fail_firstboolDefault::default()The first upload attempt fails (demos the error and Retry).
start_croppingboolDefault::default()Open the cropper on mount with `src` (demos the crop state).
removablebooltrueShow Remove.
disabledboolDefault::default()Disabled.
nowrequiredClockMs—Shared clock (the progress ring).
on_uploadEventHandler<(f32, f32, f32)>—Saved: the crop square as (centre x, centre y, side) fractions of the image.
on_removeEventHandler<()>—Removed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
TabAvatar, Upload / Replace, Remove; while cropping the crop area, zoom, Save, Cancel
ArrowsMove 2 % (Shift 10 %)
or−Zoom
0Reset
EnterSave and upload
EscapeCancel

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 AvatarUpload from oxyn_dioxus and include STATUS_INDICATOR_CSS plus the token stylesheet once.
  • A GPUI version exists: AvatarUploadEl in oxyn_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.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI