Skip to content

Context switcher

The area's working context, always visible in the top bar; every page below implies it.

View as Markdown

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>

API

React props (NxKit)

React (NxKit) props
PropTypeDefaultRequiredDescription
labelstringRequiredWhat the context is; names the button ("Brand: IPM Facility").
optionsNxContextOption[]Requiredid, label, color?, active?, href?
allLabelstringundefinedA "no context" option (id ""); omit when a context is required.
manage{ label; href }undefinedLink to the page that manages the options.
onSelect(id: string) => voidundefinedCalled with the chosen id; the host persists it.
headingstringundefinedOptional label above the options in the open menu.

Classes

Framework-agnostic classes
ClassDescription
.nx-contextPill trigger on .nx-dropdown
.nx-context__dotOptional valid option colour
.nx-shell__contextNxAppShell 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.

View in spec