Skip to main content

WorkspacePicker

Coreinput

Choose the workspace or project directory a session runs against, from recents or a typed path.

import { WorkspacePicker } from "@elabs-ai/components-ui";
Install
npm install @elabs-ai/components-tokens @elabs-ai/components-ui

Skipping the @source line is the most common first failure: Tailwind does not scan node_modules, so every component renders unstyled. The one-time wiring

Prompt for your coding agent

Paste it into Claude Code, Cursor, Codex or any other coding agent. Text in [brackets] is yours to fill in.

Add the brand-ui WorkspacePicker component (from @elabs-ai/components-ui) to this project.

1. Read https://elabs-ai.com/llms.txt first: it maps every package and the rules. If you can use MCP servers, connect https://elabs-ai.com/mcp and use its search, docs and tokens tools. If not, run the same lookups in the terminal: `npx -y @elabs-ai/components-cli search "<what you need>"` and `npx -y @elabs-ai/components-cli docs <Component>`.
2. Look WorkspacePicker up before writing code: `npx -y @elabs-ai/components-cli docs WorkspacePicker` prints its real props, variants, what it pairs with and what to avoid.
3. If @elabs-ai/components-ui is not installed yet: `pnpm add @elabs-ai/components-tokens @elabs-ai/components-ui` (or `npm install @elabs-ai/components-tokens @elabs-ai/components-ui`). If this is the first brand-ui package in the project, wire it once: import `@elabs-ai/components-tokens/styles.css` plus the `themes/light.css` and `themes/dark.css` stylesheets in the CSS entry, add one Tailwind `@source` line per installed @elabs-ai package (Tailwind does not scan node_modules, so without it everything renders unstyled), and wrap the app root in `ThemeProvider` from `@elabs-ai/components-tokens`.
4. Use it here: [the screen or file, and what it should show]
5. Rules: use only @elabs-ai/components-* components and the semantic tokens — no raw colours, no raw font sizes, no arbitrary Tailwind values. Look up each component's real props with the docs tool before you use it; never guess a prop.
6. Done means: the typecheck passes, `npx -y @elabs-ai/components-cli audit src --strict` reports nothing, and you have opened the app and looked at every screen you touched in the light and the dark theme.

Avoid

  • Re-implementing the picker list — WorkspacePicker composes ModelPicker; a second searchable-popover list is the duplication this component exists to avoid.
  • Marking the current workspace with a glyph alone — the marker is a word in the accessible name (1.4.1).
  • Reading the filesystem — the component takes a workspace list as a prop and never enumerates directories itself.
  • Natively disabling the path submit — an empty field uses aria-disabled plus a handler guard, so focus is never stranded.

Works with

Used inside

Pairs with

Examples

7 live examples

Current Workspace Marked In Text

The current workspace is marked in the row's TEXT (a "Current" badge, not only `ModelPicker`'s check glyph) — open the popover to see it, and confirm it survives a greyscale render.

No Current Workspace

No workspace chosen yet — the trigger falls back to a designed placeholder.

Empty

Nothing to show — `ModelPicker`'s own designed empty panel (reused, not reimplemented) plus the free-text path entry, which always renders in the footer regardless of body state and is this state's one action.

Long Path

A very long, deeply nested path truncates instead of overflowing the row.

Disabled

Submit Free Text Path

The free-text path entry validates non-empty and reports the raw string — this component performs no filesystem access of any kind (D5). Also proves Enter submits the path instead of being hijacked by cmdk's own list navigation (both bind a keydown handler on the same `Command` root).

API

WorkspacePicker

PropTypeDescription
workspacesrequiredWorkspace[]Recent workspaces, most-relevant first — the caller owns ordering.
currentIdstringThe currently open workspace's id.
onSelect(workspace: Workspace) => voidFires with the chosen workspace; the popover closes first.
onSubmitPath(path: string) => voidFree-text path entry, rendered in `ModelPicker`'s `footer` slot below the list. Fires with the raw string the user typed once it validates as non-empty — this component performs no filesystem access of any kind (presentation layer, D5); resolving, normalizing or checking the path is the caller's job.
statusModelPickerStatusDrives the same four-body state grid as `ModelPicker` — see `ModelPickerStatus`. Default `"ready"`, inherited from `ModelPicker`.
disabledboolean
openbooleanControlled popover open state — see `ModelPicker`'s controlled contract.
onOpenChange(open: boolean) => void

Also accepts: Omit<HTMLAttributes<HTMLDivElement>, "onSelect">

ModelPicker

PropTypeDescription
groupsrequiredreadonly ModelPickerGroup[]Grouped rows. Grouping and heading text are the caller's, never derived.
valuestringThe currently pinned row's id.
onSelect(item: ModelPickerItem) => voidFires with the chosen row; the popover closes first.
statusModelPickerStatusDrives the four bodies — see `modelPickerBody`. Default `"ready"`.
triggerLabelrequiredReactNodeTrigger text — usually the pinned row's label.
onRetry() => voidRetry action for the error strip and the empty panel. Omit to hide it.
searchPlaceholderstringSearch field placeholder.
disabledboolean
contentClassNamestringExtra classes for the popover panel (default width `w-96`).
openbooleanControlled popover open state. Omit for the uncontrolled default (internal `useState(false)`, unchanged). `isControlled = open !== undefined` and the mode never flips mid-life — see `component-api.md` "Controlled/uncontrolled".
onOpenChange(open: boolean) => voidFires whenever the popover would open/close — a trigger click, or a row select.
footerReactNodeRendered inside the popover BELOW the list — a persistent action row that is not one of the options (a free-text entry, a "browse…" affordance). Outside `CommandList` on purpose: it must not be filtered by the search query and must not participate in cmdk's roving selection.

Also accepts: Omit<HTMLAttributes<HTMLDivElement>, "onSelect">

Input

Also accepts: InputHTMLAttributes<HTMLInputElement>

Button

variant
default (default)secondarydestructiveoutlineoutline-subtleghostlink
size
smdefault (default)lgiconicon-smicon-lg
PropTypeDescription
asChildbooleanRender the child element as the button (Radix Slot) instead of a <button>.

Also accepts: ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants>

Theming

The tokens each state resolves to. Change the token and every theme follows.

StateToken
currentthe in-force workspace appends a WORD into the row meta, so it reaches the option's accessible name
emptythe free-text path submit is aria-disabled, never natively disabled, so it stays a focusable tab stop