MenuIdentityItem
HkMenuIdentityItem is the identity row at the top of a user menu: a round avatar beside a name and an optional subtitle, with an optional run of badges under them. The avatar is an image when you give it a URL and a letter chip when you do not, and a URL that fails to load falls back to the same chip instead of the browser's broken-image glyph.
- It is a presentation row, not a control: it has no click handler, no focus target and no hover state on either side, so the account actions next to it are built from separate rows such as MenuActionItem.
- Its padding is the menu panel's own row padding with a reserved transparent border, so it lines up with the action rows and the navigation rows above it in the same list.
- A group of rows under a caption is MenuSection; a navigation row with its own states is NavItem.
Import
;
use *; // MenuIdentityItem
use *; // MenuIdentityItemProps, rsx!, VNode
The Rust form is a plain function, MenuIdentityItem(MenuIdentityItemProps { … }), and the struct is in the prelude. Inside rsx! every prop may be omitted — all five fields default — so an empty block renders the "?" chip with an empty text column. Vue's #badges slot is the badges field, and it is an Option<Element>: write badges: Some(rsx! { … }).
The mirror is a line-for-line port of the Vue render: the two produce the same class names from the same stylesheet (vendored into the crate with no_hash, so .hk-menu-identity-item* is literal on both sides). Two behavioural deltas are documented below rather than left to be discovered.
Avatar, letter fallback and the alt text
The avatar cell is 36px across with aria-hidden="true" — the avatar is decoration, and the name beside it is the identity. What fills the cell depends on avatarUrl:
- a truthy URL renders <img> with object-fit: cover; the alt text is avatarAlt, or name when avatarAlt is empty (Vue renders avatarAlt || name; Rust's menu_identity_img_alt is the same function);
- an empty URL, or a URL the browser failed to load, renders the letter chip: the first character of name, uppercased, or ? when there is no name. The failed-load latch is shared with HkAvatar and HkAvatarButton (useAvatarImage) and is per URL, so a new avatarUrl gets a fresh attempt instead of staying broken for the life of the row.
name and subtitle are each rendered only when non-empty, so an empty string means "no line" rather than an empty line. A name longer than the column ellipsizes; both lines are white-space: nowrap with text-overflow: ellipsis.
The failed-load latch is Vue-only, because it is state that survives between renders: the Rust mirror has no per-instance state and renders the img branch whenever avatar_url is non-empty, so a stale URL in a Rust form keeps the browser's broken-image glyph until the host passes a different URL.
Badges, and the empty-slot band
The #badges slot renders inside div.hk-menu-identity-item__badges, a wrapping flex row 2px under the subtitle. Chips put there keep their own size and ink; the row only aligns and wraps them.
The wrapper exists whenever the slot was provided, even if it holds nothing — exactly like a provided-but-empty Vue slot, which keeps a padded band. In Vue the slot is tested for presence (slots.badges && …), so passing an empty function still renders the wrapper; in Rust a provided badges: Some(…) renders it too, including Some(empty_vnode()). Omit the slot, or pass None, to get no wrapper at all.
The chips in the Vue example are Tag chips. The Rust crate has no mirror of that component (its Tag is an unrelated legacy surface), so the Rust example keeps the chip look with a span.hk-badge, the class the library's badges already use.
The fallback letter, byte for byte
Vue reads (name || "?").charAt(0).toUpperCase(); Rust's menu_identity_fallback_initial reads the first char of the name and uppercases it. For ASCII and for BMP letters the two agree, including the expansion cases both engines share ("ß".toUpperCase() is "SS" on both sides).
They disagree on astral characters. JavaScript's charAt(0) addresses a UTF-16 code unit, so a name that starts with an emoji yields half a surrogate pair, and toUpperCase leaves it unchanged; a Rust char is one Unicode scalar, so the mirror shows the emoji itself. Names that start with a combining mark or a variation selector behave the same way: Vue takes one code unit, Rust one scalar. Keep the first character a plain letter when the fallback chip matters.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| avatarUrl | String | "" | — |
| name | String | "" | — |
| subtitle | String | "" | — |
| avatarAlt | String | "" | — |
Rust
Props — MenuIdentityItem
| Prop | Type | Default | Description |
|---|---|---|---|
| avatar_url | String | "" | Avatar image URL; empty renders the letter fallback (Vue: avatarUrl). |
| name | String | "" | Primary line (Vue: name, default ""). |
| subtitle | String | "" | Secondary line under the name — login email, department… (Vue: subtitle, default ""). |
| avatar_alt | String | "" | Accessible label for the avatar image; empty falls back to name (Vue: avatarAlt, default ""). |
| badges | Option<Element> | None | The badges run (Vue: the #badges slot). |
Accessibility
- The row itself is role="presentation" and binds no handlers, so nothing in it is focusable and no state is announced. A menu that needs "open account settings" puts a real control next to it rather than making this row clickable.
- The avatar cell is aria-hidden="true", which means the alt on the <img> is never announced: the name line is what a screen reader reads. avatarAlt is still worth setting for the case where the image is reached outside that hidden cell (a copy-pasted URL, a context-menu "open image"), and it falls back to name when empty.
- The letter chip is a span inside the hidden cell, so it is not announced either — a fallback avatar never reads as a stray letter after the name.
- The name and the subtitle are plain spans in a column, so they are read in order ("Ada Lovelace, Owner") with no separator but the layout; keep the subtitle a clarifying phrase rather than a second name.
- Badges render inside the text column and are not hidden, so their text (the chips in the example, or a hand-written string) is announced after the subtitle. Two short chips read well; a long string does not.
Related components
- MenuActionItem — the interactive rows under this identity block.
- MenuSection — the captioned run that groups those rows under the identity block.
- NavItem — the navigation row, when the row in question is a destination rather than an identity.
- NavSidebar — the ready-made navigation band whose rows share this row's leading edge.

