Avatar
A circular user image with a text fallback.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The avatar registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/avatar_component.rb -
app/helpers/ui/avatar_helper.rb -
vendor/shadwire/shadwire.css
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Or render Ui::AvatarComponent directly:
Examples
Image, fallback and label
Render an image with a fallback, or a fallback on its own for users with no photo.
API reference
ui_avatar(**options, &block) wraps Ui::AvatarComponent.new(**options).
| Argument | Type | Default | Description |
|---|---|---|---|
src | String | nil | The image URL. |
alt | String | "" | The image's alt text. |
fallback | String | nil | Initials or a symbol shown when there is no image. |
**attrs | Hash | {} | Free-form HTML attributes on the wrapper. |