shadcn.io is not affiliated with official shadcn/ui
Multi-Tenant Navbar Block for React
An app bar with two chained scopes, organization then project: choosing an organization rewrites the project list, and a role badge sits beside the organization's name.
Installation
Overview
A two-level scope switcher for React with Base UI, in the app bar of a multi-brand help desk called Tenantry. One bar between the page's rails, cut into cells by solid dividers that meet the top rule: the wordmark, then the scope cell with an organization button (a tile, the name and your role as a badge), a slash and a project button, then Inbox, Reports and Customers, then a Shine Button in a cell of its own. Each button opens a menu of radio rows over the page. Choosing an organization rewrites the project list and picks its first project, the project button swaps in place, and a polite line says what changed; choosing a project changes only the project. On a phone the scope shows as text in the bar and a sheet from the top holds the links and the same choice as a nested list. It's built from Dropdown Menu, Badge, Sheet, Guides, Shine Button and Button, with your theme's tokens for every colour. For products where one person works across several customers, brands or accounts.
FAQ
How do I change the organizations and their projects?
Edit ORGS at the top of the file: each organization has an id, a name, a tile, the role the viewer holds in it and a list of projects (an id, a name and an open-ticket count). The menus, the role badge, the sheet's nested list and the width of both buttons are all built from it. The organizations, roles and counts are made up for the demo; in an app, replace pickOrg and pickProject with your session's scope change.
What happens to the project when I change the organization?
The project list belongs to the organization, so the project is set to the new organization's first project, the project button swaps its label in place (no skeleton, no flash) and the status line says "Switched to Sablewick Books, role Admin. Project: Orders." Choosing the organization you are already in changes nothing. Both buttons are drawn over unseen copies of every possible label, so neither changes width and the bar keeps its height.
How does it work with a keyboard and a screen reader?
Each button is named for what it holds ("Organization: Cinderbay Outfitters Owner", "Project: Support"), says whether its menu is open and which menu it controls. The slash between them is decoration and is hidden from screen readers. The rows are radio items: the chosen one is checked. Escape closes the menu and returns focus to the button, and so does choosing a row, with the keyboard or the pointer. Enter, Space or the Down arrow opens the menu with focus on the first row; the arrow keys, Home and End move between rows, Enter chooses and Escape closes it.
How does it work on a phone?
Below the md breakpoint the wordmark's icon, the scope as a line of text ("Cinderbay Outfitters / Support", truncated) and a menu button are all that stay in the bar; nothing wraps at 320 pixels. The sheet from the top lists the organizations (the chosen one pressed), the projects of that organization, the links and the action. Choosing an organization updates the project list under it and keeps the sheet open; choosing a project closes it, and focus goes back to the menu button.
Does it work right to left?
Yes. The bar mirrors, the dividers stay between the cells, the menus open under the button's start edge, and the checks and the sheet follow the direction. The wordmark is artwork and keeps its direction.
Wrap the block in your direction provider (the catalog's DirectionProvider) so the menus follow the page.
Related
- Pro
Workspace Switcher Navbar
Accounts and scopesAn app bar whose switcher button opens a searchable list of workspaces: recent ones first with number keys, a plan badge on every row, a check on the current one and a Create workspace button in the foot.
- Pro
Environment Switcher Navbar
Accounts and scopesAn app bar with a Production, Staging and Development segment control that shows the environment's base URL with a copy button and asks for confirmation before switching to Production.
- Pro
Role-Based Navbar
Accounts and scopesAn app bar with a View as toggle (Admin, Editor, Viewer) that swaps the bar's links in one cell, so its width never moves, with a role badge that says what the role can do.
- Pro
Split Layout Navbar
Cells and splitsAn app bar split by a solid divider that meets the top rule: navigation at the start, and at the end a help link and an avatar whose menu sets your presence (Active, Away, Do not disturb) and recolours its dot.
- Pro
Workspace Top Bar Banner
Utility barsA top bar for a team workspace manager that says which workspace you are in, with your role as a badge and a Switch menu of workspaces behind a divider.
- Pro
SaaS Marketing Navbar
Mega menusA one-bar marketing navbar for a product roadmap tool: a wordmark, a Product menu of four areas with icons and one-line descriptions, plain links with the current page marked, Sign in and a Shine Button, and a sheet with the same links on phones.