Skip to content

CSS: avatar

.instui-avatar · stable — Yon avatar itilizatè ki montre inisyal oswa yon imaj, sikilè pa default.

Pa default koulè palèt la teni inisyal yo sou yon sifas transparan; -has-inverse-color ranpli sifas la ak koulè a epi mete inisyal yo sou-koulè. Variant -color-ai toujou ranpli ak dégradé violet→lanmè a. Pou yon non konplè montre, mete li nan kontni an (konsa li rete nan pye aksè a) epi ajoute data-initials="XX" pou vizyèl konpak la — tèks reyèl la se sa yon lektè ekran anonse. San data-initials, kontni ki debòde jis koupe di (pa gen elips); anvlòp li nan .name pou yon koupe egzak ki montre sèlman lèt premye a, oswa separe li an .first-name/.last-name pou de lèt koupe (nenpòt mwatye ka omit e lòt la rete santre).

Source: avatar.css

TIP

Amelyorasyon JS — CSS konpozan sa a rann li epi fonksyone pou kont li; pè li ak @pantoken/interactions pou ajoute konpòtman entèaktif la. Gade tab modifyè anba a.

Aksè

Bay yon avatar imaj yon alt ki gen sans (non moun nan), pa yon "avatar" jeneral; pou avatar ki gen sèlman inisyal, prefere kontni non reyèl (tèks senp, data-initials, .name, oswa .first-name/.last-name) olye de lèt pre-abreje, konsa teknoloji asistif ap anonse non reyèl la.

Itilizasyon

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/avatar.css";

Egzanp

html
<span class="instui-avatar --me-sm">LH</span>
<span class="instui-avatar -color-ai --me-sm">AI</span>
<span class="instui-avatar --me-sm" data-initials="NV">Dr. Nguyen Van Thoc</span>
<span class="instui-avatar"><span class="name">Miguel Sanchez</span></span>
<span class="instui-avatar"><span class="first-name">Miguel</span> <span class="last-name">Sanchez</span></span>

Estrikti

Avatar la montre youn nan: yon <img>, tèks vid/data-initials, yon anvlòp .name, oswa yon pè .first-name/.last-name.

text
.instui-avatar
  img (0..1)
  .name (0..1)
  .first-name (0..1)
  .last-name (0..1)
flowchart TD n0[".instui-avatar"]:::cssdoc-root n1("img"):::cssdoc-part n2(".name"):::cssdoc-part n3(".first-name"):::cssdoc-part n4(".last-name"):::cssdoc-part n0 -.->|0..1| n1 n0 -.->|0..1| n2 n0 -.->|0..1| n3 n0 -.->|0..1| n4 classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

Modifikatè

ModifikatèDeskripsyon
.-color-accent1Depreke — use .-color-blue.
.-color-accent2Depreke — use .-color-green.
.-color-accent3Depreke — use .-color-red.
.-color-accent4Depreke — use .-color-orange.
.-color-accent5Depreke — use .-color-ash.
.-color-accent6Depreke — use .-color-grey.
.-color-aiKoulè palèt aksan AI.
.-color-ashKoulè palèt Ash.
.-color-blueKoulè palèt Ble.
.-color-greenKoulè palèt Vèt.
.-color-greyKoulè palèt Gri.
.-color-orangeKoulè palèt Jòn-orangé.
.-color-redKoulè palèt Wouj.
.-has-inverse-colorSèvi ak koulè tèks envès la (sou fon fonse).
.-shape-rectangleFòm kare (rektangilè) olye de sèk.
.-show-borderAlias — maps to .-show-border-always.
.-show-border-alwaysFòse bag fwontyè a sou, menm sou yon imaj oswa yon ranpli envès.
.-show-border-neverFòse bag fwontyè a etenn.
.-size-2xlDe gwosè pi gwo.
.-size-2xsDe gwosè pi piti.
.-size-largeGwo. Alias long fòm pou -size-lg.
.-size-lgGwo.
.-size-mdMwayen (default la).
.-size-mediumMwayen (default la). Alias long fòm pou -size-md.
.-size-smTi.
.-size-smallTi. Alias long fòm pou -size-sm.
.-size-x-largeEkstra gwo. Alias long fòm pou -size-xl.
.-size-x-smallEkstra piti. Alias long fòm pou -size-xs.
.-size-xlEkstra gwo.
.-size-xsEkstra piti.
.-size-xx-largeDe gwosè pi gwo. Alias long fòm pou -size-2xl.
.-size-xx-smallDe gwosè pi piti. Alias long fòm pou -size-2xs.

Pati

PatiDeskripsyon
.first-nameOpsyonèl (mache ak .last-name): anvlòp non bay la, koupe pou montre lèt premye li.
.last-nameOpsyonèl (mache ak .first-name): anvlòp non fanmi an, koupe pou montre lèt premye li.
.nameOptional: wrap the full name to clip it to a single leading letter without data-initials or JS.

Pseudo-eleman

Pseudo-elemanDeskripsyon
::before

Tokens konsome

TokenTipValè
--instui-component-avatar-ai-bottom-gradient-color<color>#00828E
--instui-component-avatar-ai-top-gradient-color<color>#9E58BD
--instui-component-avatar-ash-background-color<color>LightDarklight-dark(#273540, #1C222B)
--instui-component-avatar-ash-text-color<color>LightDarklight-dark(#273540, #C7CACD)
--instui-component-avatar-background-color<color>LightDarklight-dark(#ffffff, #10141A)
--instui-component-avatar-blue-background-color<color>#2B7ABC
--instui-component-avatar-blue-text-color<color>LightDarklight-dark(#2871AF, #7FB4F1)
--instui-component-avatar-border-color<color>LightDarklight-dark(#8D959F, #6A7883)
--instui-component-avatar-border-width-md<length>0.125rem
--instui-component-avatar-border-width-sm<length>0.0625rem
--instui-component-avatar-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-avatar-font-size-lg<length>1.25rem
--instui-component-avatar-font-size-md<length>1rem
--instui-component-avatar-font-size-sm<length>0.875rem
--instui-component-avatar-font-size-xl<length>1.75rem
--instui-component-avatar-font-size-xs<length>0.75rem
--instui-component-avatar-font-size2xl<length>2.5rem
--instui-component-avatar-font-size2xs<length>0.75rem
--instui-component-avatar-font-weight<integer>600
--instui-component-avatar-green-background-color<color>#03893D
--instui-component-avatar-green-text-color<color>LightDarklight-dark(#037D37, #61C378)
--instui-component-avatar-grey-background-color<color>LightDarklight-dark(#4A5B68, #576773)
--instui-component-avatar-grey-text-color<color>LightDarklight-dark(#4A5B68, #F2F4F5)
--instui-component-avatar-orange-background-color<color>#CF4A00
--instui-component-avatar-orange-text-color<color>LightDarklight-dark(#BB4200, #FF905A)
--instui-component-avatar-rectangle-radius<length>0.25rem
--instui-component-avatar-red-background-color<color>#E62429
--instui-component-avatar-red-text-color<color>LightDarklight-dark(#CF1F24, #FA917F)
--instui-component-avatar-size-lg<length>3.5rem
--instui-component-avatar-size-md<length>3rem
--instui-component-avatar-size-sm<length>2.5rem
--instui-component-avatar-size-xl<length>4rem
--instui-component-avatar-size-xs<length>2rem
--instui-component-avatar-size2xl<length>5rem
--instui-component-avatar-size2xs<length>1.5rem
--instui-component-avatar-text-on-color<color>#ffffff

Ki gen rapò

  • byline — Ka òganize yon avatar kòm figi prensipal li.