Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

The list

A labelled group of accounts, where the current one carries a tick and is marked for screen readers.

Accounts with the current one marked
Show code
<app-account-switcher current-id="b" label="Switch account">
    <app-account value="a" name="Acme Corp" badge="Owner" />
    <app-account value="b" name="Globex Ltd" description="Finance team" />
    <app-account value="c" name="Initech" href="#initech" />
</app-account-switcher>

In the user menu

Placed in the account menu, the switcher sits under the person's name and above the menu rows.

The switcher in an account menu
Skip to content

Dashboard

Page content

Show code
<app-shell no-sidebar="true">
    <app-shell-brand><span class="app-sidebar-brand-text card-title">Acme</span></app-shell-brand>
    <app-shell-user-menu name="Priya Sharma" role="Senior Developer" profile-href="/Demo/Shell/Profile" logout-action="/Demo/Shell?handler=Logout">
        <app-shell-user-menu-section>
            <app-account-switcher current-id="b" label="Switch account">
                <app-account value="a" name="Acme Corp" badge="Owner" />
                <app-account value="b" name="Globex Ltd" description="Finance team" href="#globex" />
                <app-account value="c" name="Initech" href="#initech" />
            </app-account-switcher>
        </app-shell-user-menu-section>
    </app-shell-user-menu>
    <app-shell-topbar-start><h2 class="card-title m-0">Dashboard</h2></app-shell-topbar-start>
    <app-shell-content><p class="m-0">Page content</p></app-shell-content>
</app-shell>

Every option

Every value of every prop, one cell each.

accounts

no app-account children (default): renders nothing
app-account: one row
app-account description: a line under the name
app-account badge: a trailing pill
app-account photo: initials without one
app-account href: a link row

currentId

current-id="acme"
current-id="globex"
current-id="initech"
current-id="none": falls back to the first account

onSelect

onSelect (React): fires with the account; here a button with data-account-id

label

label="Switch account" (default)
label="Choose a company"

linkComponent

linkComponent (React): a router link for href rows; here a plain link

Guidance

What to do, and what to avoid.

Use it when

  • A person signed in to more than one account, company or organisation, and needs to see which one is current.
  • The switcher sits in the user menu's section slot of AppShell.

Reach for something else when

  • You are switching the workspace or tenant in the chrome. → AppWorkspaceSwitcher
  • You need a flat list of actions behind a trigger. → AppDropdown
  • You are picking a value into a form field. → AppSelect

Offer switching only with several accounts

Do

The current account is ticked, and each other account is one row to switch to.

Avoid

A list of one account. There is nothing to switch to, so the section does not earn its place.

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

acme globex initech
React, generated from the controls
<AppAccountSwitcher
  accounts={accounts}
  currentId="globex"
  onSelect={(account) => switchAccount(account.id)}
/>
Razor, the same props
<app-account-switcher current-id="globex">
    <app-account value="acme" name="Acme Corp" badge="Owner" />
    <app-account value="globex" name="Globex Ltd" description="Finance team" href="#globex" />
    <app-account value="initech" name="Initech" href="#initech" />
</app-account-switcher>

3 props. The 2 most used come first.

Used on most screens 2 props

PropTypeDefaultDescription
current-iddefault - string - The id of the current account. It sets the tick and aria-current, and falls back to the first account when it matches none.
labeldefault Switch account string Switch account The heading above the list. It is also the group's accessible name.

Less common 1 props

PropTypeDefaultDescription
(app-account children)default - - - The accounts a person can switch to, one app-account child each.

Screen reader

3 notes
  • The list is a group named by label.
  • The current account carries aria-current and a tick, so the state is not shown by colour alone.
  • A row with an href is a link; a row without one is a button.

Do and avoid

1 pairs

Offer switching only with several accounts

Do

The current account is ticked, and each other account is one row to switch to.

Avoid

A list of one account. There is nothing to switch to, so the section does not earn its place.