Images and accessible initial fallbacks at predictable sizes.
app/components/nitro_kit/avatar.rbNitroKit::Avatar.new(src:, alt:, fallback:, size:)All closed sizes keep fallback text, geometry, and accessibility semantics aligned.
test/dummy/app/components/gallery/components/avatar_page.rbGallery::Data.avatar_sizes.each do |avatar|
sample(avatar.label, slug: avatar.slug) do
render_avatar(avatar)
end
endImage, generated initials, custom long fallback, and anonymous states are explicit.
test/dummy/app/components/gallery/components/avatar_page.rbsample("Image", slug: "image") do
render NitroKit::Avatar.new(
src: "/icon.svg",
alt: "Nitro Kit mark",
fallback: "NK",
size: :lg,
id: "gallery-avatar-image"
)
end
sample("Generated initials", slug: "generated-initials") do
render NitroKit::Avatar.new(
alt: "Alexandria Ocasio-Cortez",
size: :lg,
id: "gallery-avatar-generated"
)
end
sample("Long custom fallback", slug: "long-fallback") do
render NitroKit::Avatar.new(
alt: "Platform engineering team",
fallback: "TEAM",
size: :lg,
id: "gallery-avatar-long-fallback"
)
end
sample("Anonymous", slug: "anonymous") do
render NitroKit::Avatar.new(size: :lg, id: "gallery-avatar-anonymous")
endFallback-only identities label the root; image identities retain native alt text.
test/dummy/app/components/gallery/components/avatar_page.rbrender NitroKit::Avatar.new(
alt: "Katherine Johnson",
fallback: "KJ",
id: "gallery-avatar-labelled-fallback"
)
render NitroKit::Avatar.new(
src: "/icon.svg",
alt: "Nitro Kit workspace",
fallback: "NK",
id: "gallery-avatar-labelled-image"
)