Documentation Upgrade
Start here
CwProfileMenu combines a user trigger, optional avatar, and action menu. The menu stays simple: you pass the items and react to whichever item the user picks.
Copy-paste examples
These snippets intentionally show the full public API surface the live demo relies on.
Standard profile menu
Use `onselect` to branch on the selected item id.
<script lang="ts">
const menuItems = [
{ id: 'profile', label: 'My profile' },
{ id: 'settings', label: 'Account settings' },
{ id: 'signout', label: 'Sign out', separator: true, danger: true }
];
</script>
<CwProfileMenu
name="kevin@cropwatch.io"
subtitle="Administrator"
menuItems={menuItems}
onselect={(item) => {
if (item.id === 'signout') signOut();
}}
/>
Custom avatar and trigger icon
Use snippets when the default initials or avatar image are not enough.
<CwProfileMenu name="North greenhouse" menuItems={menuItems}>
{#snippet avatar()}
<div style="width:100%;height:100%;display:grid;place-items:center;background:#0f766e;color:white;font-weight:700">
NG
</div>
{/snippet}
{#snippet icon()}
<svg viewBox="0 0 16 16" fill="none" style="width:1rem;height:1rem">
<path d="M4 6l4 4 4-4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
{/snippet}
</CwProfileMenu>