Pick one role. Built-in roles come first, custom ones after, each with a short line of what it can do and how many people hold it. A role you cannot give stays in the list with the reason.
On this page
Used for
- Member rows
- Invite forms
- Project access
- Sharing dialogs
- Admin tables
Examples
Size
In a table row
In an invite form
Installation
npx knowns-ui@latest add role-pickerFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Role picker from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/role-picker
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add role-picker
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/avatar.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- components/ui/knowns/dialog.tsx
- components/ui/knowns/kbd.tsx
- components/ui/knowns/field-class.ts
- components/ui/knowns/textarea.tsx
- components/ui/knowns/chat-composer/use-autosize.ts
- components/ui/knowns/input.tsx
- components/ui/knowns/menu.tsx
- components/ui/knowns/tag.tsx
- components/ui/knowns/combobox.tsx
- lib/knowns/permissions.ts
- components/ui/knowns/role-picker.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/role-picker, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "role-picker" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- rolesrequired
Role[]- { id, name, description?, builtIn?, memberCount?, permissions?, disabled?, disabledReason? }.
- value / onValueChangerequired
string|null / (id | null) => void- The picked role id. null is the none entry, or nothing picked.
- noneOption
{ label, description? }- A first entry that picks null, e.g. No project role.
- catalog
PermissionGroup[]- To write each role's line from its permissions, e.g. "Edit any issue, Manage labels +12".
- size
"sm"|"md"- Default
"md" - sm is 28px for table rows (160px wide), md 32px for forms (full width).
- disabled
boolean- Default
false - The whole field.
- placeholder
string- Default
"Pick a role" - Shown when nothing is picked.
- aria-label
string- Name it after what it sets: "Atlas role for Tomas Lindqvist".
- className
string- On the field.
| Prop | Type | Default | Description |
|---|---|---|---|
| rolesrequired | Role[] | required | { id, name, description?, builtIn?, memberCount?, permissions?, disabled?, disabledReason? }. |
| value / onValueChangerequired | string | null / (id | null) => void | required | The picked role id. null is the none entry, or nothing picked. |
| noneOption | { label, description? } | - | A first entry that picks null, e.g. No project role. |
| catalog | PermissionGroup[] | - | To write each role's line from its permissions, e.g. "Edit any issue, Manage labels +12". |
| size | "sm" | "md" | "md" | sm is 28px for table rows (160px wide), md 32px for forms (full width). |
| disabled | boolean | false | The whole field. |
| placeholder | string | "Pick a role" | Shown when nothing is picked. |
| aria-label | string | - | Name it after what it sets: "Atlas role for Tomas Lindqvist". |
| className | string | - | On the field. |
Accessibility
- It is a Combobox: a button with aria-haspopup="listbox", arrow keys through the roles, type-ahead, Enter to pick and Escape to close.
- A role you cannot give is aria-disabled and its reason is part of its description, so it is read with the name.
- On phones the list opens as a sheet titled with the field's label.
What it handles
- 01Lists built-in roles first and custom ones after, with small headers when both kinds are there.
- 02Gives every role a second line: its strongest permissions from the catalog (or its description) and how many members hold it.
- 03Keeps a role you cannot give in the list, off, with the reason as its second line.
- 04Adds an optional first entry such as No project role that picks null, and turns search on from seven entries.
States
- Open
- The list fades in under the field
- 120ms, ease out
- Pick
- The field shows the role at once
- none
- Reduced motion
- The list appears at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| Open | The list fades in under the field | 120ms, ease out |
| Pick | The field shows the role at once | none |
| Reduced motion | The list appears at once | 0ms |
Works with
When to use
When to use
- Giving a person one role in a member row, an invite form or a share dialog.
- A project role that can fall back to the workspace role, with a No project role entry.
When not to use
- Editing what a role can do: use Permission Matrix.
- Picking several values or plain options: use Combobox.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Role Picker to my app and wire it to my own data.
- I need giving a person one role in a member row, an invite form or a share dialog. Set that up with the Knowns UI Role Picker.
- Which Role Picker props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "role-picker" }) and search_docs({ query: "role picker" }).