Profile Image
<wa-profile-image>
Displays an editable profile image with an image picker and square crop workflow.
Examples
Handle the saved image
The component emits a native change event after the crop is saved. Read the resulting Blob from value.
Labels
Use label for the picker and avatar's accessible name. The crop dialog and confirmation button have separate visible labels.
Sizes
Use Web Awesome's s, m, and l size values.
Accepted image types
Use accept with the same syntax as a native file input.
Notes
- The default accepted formats are JPEG and PNG.
- The saved crop is a square
560 × 560image blob. - Override
--sizefor a custom avatar size and--cropper-sizefor a custom crop surface. - Use
disabledwhen the current image must remain visible without allowing replacement.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://cdn.yoummday.com/packages/@yoummday/webawesome/0.5.1/dist/components/profile-image/profile-image.js';
After installing Web Awesome via npm, import this component:
import '@yoummday/webawesome/dist/components/profile-image/profile-image.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/profile-image/profile-image.js';
To import this component for React 18 or below, use the following code:
import WaProfileImage from '@yoummday/webawesome/dist/react/profile-image/index.js';
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
acceptaccept |
Accepted image extensions or MIME types.
Type
string
Default
'.jpg,.jpeg,.png,image/jpeg,image/png'
|
|
confirmLabelconfirm-label |
The label for the button that saves the crop.
Type
string
Default
'Save'
|
|
cropLabelcrop-label |
The crop dialog's accessible label.
Type
string
Default
'Crop image'
|
|
disableddisabled |
Disables image selection.
Type
boolean
Default
false
|
|
imageimage |
The current image URL.
Type
string
Default
''
|
|
initialsinitials |
Initials shown when no image is available.
Type
string
Default
''
|
|
labellabel |
The avatar's accessible label.
Type
string
Default
'Choose profile image'
|
|
sizesize |
The profile image size preset.
Type
's' | 'm' | 'l'
Default
'm'
|
|
value |
The most recently saved cropped image.
Type
Blob | null
Default
null
|
Events
Learn more about events.
| Name | Description |
|---|---|
change |
Emitted when a cropped image is saved. Read the resulting Blob from event.target.value. |
CSS Custom Properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--cropper-size |
The preferred width and height of the crop surface.
Default
28rem
|
--size |
The width and height of the profile image.
Default
7.5rem
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
avatar |
The current avatar. |
::part(avatar)
|
confirm-button |
The button that saves the crop. |
::part(confirm-button)
|
cropper |
The square crop surface. |
::part(cropper)
|
dialog |
The crop dialog. |
::part(dialog)
|
file-upload |
The image picker. |
::part(file-upload)
|
profile-image |
The component's outer wrapper. |
::part(profile-image)
|
base |
An alias for the component's outer wrapper. |
::part(base)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.