Avatar
Initials or an image representing a person.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_avatar "AL", ink: true, class: "bg-accent", aria: { label: "Alex Lee" } %>
<%= lc_avatar "SK", size: :lg, ink: true, class: "bg-success-soft", aria: { label: "Sam Kim" } %>
<%= lc_avatar "JR", ink: true, class: "bg-warning-soft", aria: { label: "Jamie Rivera" } %>
<%= lc_avatar "MK", ink: true, class: "bg-destructive-soft", aria: { label: "Morgan Kim" } %>
Examples
Initials and images
AL
SK
JR
MK
<%= lc_avatar "AL", ink: true, class: "bg-accent", aria: { label: "Alex Lee" } %>
<%= lc_avatar "SK", size: :lg, ink: true, class: "bg-success-soft", aria: { label: "Sam Kim" } %>
<%= lc_avatar "JR", ink: true, class: "bg-warning-soft", aria: { label: "Jamie Rivera" } %>
<%= lc_avatar "MK", ink: true, class: "bg-destructive-soft", aria: { label: "Morgan Kim" } %>
Sizes
AL
AL
AL
AL
AL
AL
AL
AL
<% [ :xs, :sm, 7, :md, 11, :lg, :xl, :xxl ].each do |size| %>
<%= lc_avatar "AL", size: size, ink: true, class: "bg-accent", aria: { label: "Alex Lee (#{size})" } %>
<% end %>
Avatar groups
AL
SK
JR
<%= lc_avatar_stack aria: { label: "Alex, Sam and Jamie" } do %>
<%= lc_avatar "AL", ink: true, class: "bg-success-soft" %>
<%= lc_avatar "SK", ink: true, class: "bg-warning-soft" %>
<%= lc_avatar "JR", ink: true, class: "bg-destructive-soft" %>
<% end %>
Corner badge
AL
<div class="relative">
<%= lc_avatar "AL", size: :xl %>
<%= lc_avatar_badge "camera", label: "Change photo", as: :button %>
</div>
<div class="relative">
<%= lc_icon_badge "🏯", size: :xl %>
<%= lc_avatar_badge "lock-closed" %>
</div>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_avatar
lc_avatar(content = nil, src: nil, alt: nil, size: :md, ink: false, linked: false, as: :span, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| content | nil | — |
| src | nil | — |
| alt | nil | — |
| size | :md | :xs · :sm · :md · :lg · :xl · :xxl · :7 · :11 |
| ink | false | true · false |
| linked | false | true · false |
| as | :span | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_avatar_stack
lc_avatar_stack(compact: false, size: :md, overlap: :md, row: {}, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| compact | false | true · false |
| size | :md | — |
| overlap | :md | — |
| row | {} | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_avatar_badge
lc_avatar_badge(icon, label: nil, as: :span, size: nil, **attributes)
| Input | Default | Values |
|---|---|---|
| icon | Required | Heroicon name; spacing is handled automatically |
| label | nil | Accessible name, visible where applicable |
| as | :span | — |
| size | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
The examples also use lc_icon_badge. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.