Components
Avatars
Avatars
Avatars enable you to represent a users identity on screen.
Image avatars
heex
<.avatar size="xs" src="img_1.png" />
<.avatar size="sm" src="img_1.png" />
<.avatar size="md" src="img_1.png" />
<.avatar size="lg" src="img_1.png" />
<.avatar size="xl" src="img_1.png" />
Avatars with placeholder icon
heex
<.avatar size="xs"/>
<.avatar size="sm"/>
<.avatar size="md"/>
<.avatar size="lg"/>
<.avatar size="xl"/>
Avatars with placeholder initials
PC
PC
PC
PC
PC
heex
<.avatar name="Petal Components" size="xs" />
<.avatar name="Petal Components" size="sm"/>
<.avatar name="PC" />
<.avatar name="PC" size="lg"/>
<.avatar name="PC" size="xl"/>
Colored avatars with placeholder initials
MP
NH
JC
WS
PJ
heex
<.avatar name="Matt Platts" size="xs" random_color />
<.avatar name="Nic Hoban" size="sm" random_color />
<.avatar name="James Cameron" random_color />
<.avatar name="Will Smith" size="lg" random_color />
<.avatar name="Peter Jackson" size="xl" random_color />
Avatar groups stacked
heex
<.avatar_group avatars={[
"img_1.png",
"img_2.png",
"img_3.png",
"img_4.png",
]} size="xs"/>
<.avatar_group avatars={[
"img_1.png",
"img_2.png",
"img_3.png",
"img_4.png",
]} size="sm" />
<.avatar_group avatars={[
"img_1.png",
"img_2.png",
"img_3.png",
"img_4.png",
]} size="md" />
<.avatar_group avatars={[
"img_1.png",
"img_2.png",
"img_3.png",
"img_4.png",
]} size="lg" />
<.avatar_group avatars={[
"img_1.png",
"img_2.png",
"img_3.png",
"img_4.png",
]} size="xl" />
Properties
elixir
# Avatar
attr(:src, :string, default: nil, doc: "hosted avatar URL")
attr(:size, :string, default: "md", values: ["xs", "sm", "md", "lg", "xl"])
attr(:class, :string, default: "", doc: "CSS class")
attr(:name, :string, default: nil, doc: "name for placeholder initials")
attr(:random_color, :boolean,
default: false,
doc: "generates a random color for placeholder initials avatar"
)
attr(:rest, :global)
# Avatar group
attr(:size, :string, default: "md", values: ["xs", "sm", "md", "lg", "xl"])
attr(:class, :string, default: "", doc: "CSS class")
attr(:avatars, :list, default: [], doc: "list of your hosted avatar URLs")
attr(:rest, :global)