shadcn.io is not affiliated with official shadcn/ui
Linked Workspaces Account Block for React
The workspaces in an account as one ruled list: current and default marks, Open, a menu with Make default and Leave (which asks first), a dialog to create one, a field to join with a code, and Undo.
Installation
Overview
Let people see every team they are in and move between them, with this workspaces panel for React with Base UI. A hairline frame with a plus mark on each corner holds a ruled list: each workspace has its tile, its name, your role, how many people are in it and the day you last opened it, a "Current" Badge on the one that is open and a "Default" badge on the one that opens when you sign in. Open switches to it, and a Dropdown Menu offers Make default and Leave workspace, which asks first in an Alert Dialog and hands "current" and "default" to another workspace when it was either. The header's Shine Button is the only colored control: it opens a Dialog to create a workspace. A field under the list joins one with a code, and a line at the foot says what happened, with Undo walking back the last change. It's built from Dialog, Alert Dialog, Dropdown Menu, Field, Input, Badge, Button, Shine Button and Guides, with a CSS entrance only. For the account page of any app where one login reaches several teams.
FAQ
How do I fill it with my workspaces?
Edit WORKSPACES. Each has an id, two typed initials for the tile, a name, your role there, how many members it has and the ISO day it was last opened. Which one is open and which is the default are two ids in state, current and defaultId. "Opened yesterday" is worked out from the one AS_OF constant, never the clock, so replace it with today's date when you wire it up. The list holds up to LIMIT workspaces.
What stays local, and how do I make it real?
Everything. Opening, making a default, creating, joining and leaving change this page's state and say so in the foot; nothing is sent and nobody is told. Undo walks the changes back, which a real server can't always do. To make it real, call your endpoints in open, makeDefault, create, join and leave, change the list only when they answer, and put a failure in the same status line. The join code is printed in the interface for the demo and checked against a typed constant: check it on your server, and don't print it.
How does creating and joining work?
The header button opens a real dialog with a focus trap, Escape to close it and focus back on the button. A name that is empty, longer than thirty characters or already in the list is refused under the field and focus stays in it; a good one adds the workspace at the top, makes you its owner, opens it, closes the dialog and moves focus to its menu button. Joining takes a code in the field under the list: empty, wrong and "already in it" each get their own message, and the account is capped at six workspaces.
What happens when I leave the current or default workspace?
Leave workspace is in each row's menu and opens an alert dialog that says what you lose, that what you posted stays and that an admin can invite you again; when the workspace is open or your default it adds that another takes its place. Focus starts on Cancel, Escape closes it and focus returns to the menu button. After you confirm, focus goes to the menu button of the workspace that is current now. The menu has no Leave when only one workspace is left.
How does it look on a phone?
Each workspace is a card: the tile, name, marks and the line of facts first, then Open and the menu under them. Every row has the same height, so creating, joining, opening or leaving never moves the foot until the list is longer than four. The foot with the status line and Undo stays pinned to the bottom of the screen.
Is it accessible?
The list is a real list. Open and the menu button name the workspace ("Open Hollowtree Studio", "More for Hollowtree Studio"); on the open workspace Open stays focusable and answers "Hearthroom is already open." instead of doing nothing. Current and Default are words with icons, never colour, and the status line is a polite live region present from the start. Problems under the fields are announced and linked to their field.
Related
- Pro
Memberships Account
OrganizationsThe organisations in an account as two tabs, Memberships and Invitations, with counts: leave asks first, an invitation is accepted into the other tab or declined, a managed membership says why it stays, and Undo.
- Pro
Organization Settings Account
OrganizationsWhat it means that an employer manages an account, written for the person it belongs to: six things admins can or cannot do, the facts, and a way to leave that asks for the export first and the company's domain.
- Pro
Team Members Account
Shared accessThe people who can sign in to a shared account as hairline tiles: role menu, two-factor on or off, last sign-in, those without two-factor first with a reminder button, pending invitations and an invite form.
- Pro
Workspace Picker Login
Workspaces and rolesA sign-in page that starts from the workspaces this browser remembers: tiles on hairlines with an add cell, a password field that fills the space under the grid, and Forget with a permanent Undo.
- Pro
Policy Compliance Status Account
OrganizationsThe rules a managed account must meet by a deadline, as a bento of hairline cells: five rules with their state in words and a Fix button, a segmented bar, days to the deadline and Undo.
- Pro
Two-Factor Methods Account
Sign-in methodsAn account's two-factor methods as rows with their role, history and a Test that opens a code field in place, Make primary, a guarded Remove, and a Set up that opens a QR code, a key name or a number.