Skip to content

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
  1. Organizations
  2. When to use it
  3. For everyone
  4. Props

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 detail with 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

OrgSwitcherTypeDefault
currentrequired string
onChangerequired (id: string) => void
optionsrequired SwitcherOption[]
compact boolean
createLabel

The thing to create: «organization». Defaults to `kind`.

string
kind string
onCreate

Adds «Create …» at the end of the list.

(() => void)
onSettings

Adds a settings entry at the end of the list («Organization settings» on the OrgSwitcher).

(() => void)
settingsLabel

The words of that entry.

string
  1. Organizations
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms