OrgSwitcher
Which organization the person works in. The current one with its initials in the top bar; the others in a list, and «Create organization» at the end.
import { OrgSwitcher } from '@sypnia/ui/react'
On this page
Organizations
Code
import { useState } from 'react';
import { OrgSwitcher, toast } from '@sypnia/ui/react';
// The current organization with its initials; the others in a list; «Create organization» and its settings at the end.
export default function Orgs() {
const [org, setOrg] = useState('acme');
return <OrgSwitcher current={org} onChange={setOrg} onCreate={() => toast('Create an organization')} onSettings={() => toast('Organization settings')}
options={[{ id: 'acme', name: 'Acme', detail: 'Pro · 4 projects' }, { id: 'north', name: 'Northwind', detail: 'Free · 1 project' }, { id: 'personal', name: 'Ana Ruiz', detail: 'Personal' }]} />;
} When to use it
Use it when
- First in the top bar, before the project.
- Add
detailwith the plan or the number of projects.
Do not use it when
- People who only belong to one organization: show its name, not a switcher.
For everyone
- The button says what it switches and the current one: «Switch organization: Acme».
- The current one is checked in the list; the arrow keys move and typing jumps.
Props
| OrgSwitcher | Type | Default |
|---|---|---|
currentrequired | string | |
onChangerequired | (id: string) => void | |
optionsrequired | SwitcherOption[] | |
compact | boolean | |
createLabelThe thing to create: «organization». Defaults to `kind`. | string | |
kind | string | |
onCreateAdds «Create …» at the end of the list. | (() => void) | |
onSettingsAdds a settings entry at the end of the list («Organization settings» on the OrgSwitcher). | (() => void) | |
settingsLabelThe words of that entry. | string |