Context switcher
The area's working context, always visible in the top bar; every page below implies it.
Preview
Active brand Lives in NxAppShell's context slot. The preview opens its menu; the code is the closed trigger.
<div class="nx-dropdown nx-context">
<button type="button" class="nx-dropdown__trigger"
aria-haspopup="menu" aria-expanded="false"
aria-label="Brand: IPM Facility">
<span class="nx-context__chip">
<span class="nx-context__dot" style="background:#2a78d6"
aria-hidden="true"></span>
<span class="nx-context__value">IPM Facility</span>
<svg class="nx-context__caret" width="14" height="14"
viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" aria-hidden="true"
focusable="false">
<path d="m6 9 6 6 6-6" />
</svg>
</span>
</button>
</div><NxContextSwitcher
label="Brand"
heading="Choose brand"
options={[
{
id: "1",
label: "IPM Facility",
color: "#2a78d6",
active: true,
},
{ id: "2", label: "IPM Academy", color: "#eda100" },
]}
allLabel="All brands"
manage={{ label: "Manage brands", href: "/marketing/brands" }}
onSelect={setBrand}
/>API
React props (NxKit)
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
label | string | Required | What the context is; names the button ("Brand: IPM Facility"). | |
options | NxContextOption[] | Required | id, label, color?, active?, href? | |
allLabel | string | undefined | A "no context" option (id ""); omit when a context is required. | |
manage | { label; | undefined | Link to the page that manages the options. | |
onSelect | (id: string) | undefined | Called with the chosen id; the host persists it. | |
heading | string | undefined | Optional label above the options in the open menu. |
Classes
| Class | Description |
|---|---|
.nx-context | Pill trigger on .nx-dropdown |
.nx-context__dot | Optional valid option colour |
.nx-shell__context | NxAppShell slot after the app switcher |
Accessibility
- Menu button (NxDropdownMenu): aria-haspopup=menu, Escape/outside click close, focus returns to the trigger.
- The trigger's accessible name includes the active value; colour dots are aria-hidden and the label carries the meaning.
Do / Don’t
- Do: Persist the choice and imply it on every page below (filters, defaults, KPIs).Don't ask for the same context again in forms on those pages.