Skip to content

TopBar

The bar at the top of every signed-in page: the brand, where the person is, and the tools on the right. AppShell draws it; use it on its own when the frame is the app's own.

import { TopBar, OrgSwitcher, ProjectSwitcher, UserMenu, NotificationBell } from '@sypnia/ui/react'

On this page
  1. The bar of a console
  2. When to use it
  3. For everyone
  4. Props

The bar of a console

/
Code
import { useState } from 'react';
import { Logo, NotificationBell, OrgSwitcher, ProjectSwitcher, TopBar, UserMenu } from '@sypnia/ui/react';

// The bar of a console on its own: brand, where you are (organization / project), and the tools on the right.
export default function Console() {
  const [org, setOrg] = useState('acme');
  const [project, setProject] = useState('shop');
  return (
    <TopBar brand={<Logo product="Data" />}
      where={<div className="sy-row"><OrgSwitcher current={org} onChange={setOrg} options={[{ id: 'acme', name: 'Acme' }, { id: 'north', name: 'Northwind' }]} /><span className="sy-text--muted">/</span>
        <ProjectSwitcher current={project} onChange={setProject} options={[{ id: 'shop', name: 'shop' }, { id: 'analytics', name: 'analytics' }]} /></div>}
      tools={<><NotificationBell items={[{ id: '1', title: 'Backup finished', at: new Date(), unread: true, icon: 'backup', tone: 'ok' }]} /><UserMenu name="Ana Ruiz" email="ana@northwind.io" onSignOut={() => {}} /></>} />
  );
}

When to use it

Use it when

  • Apps that do not use AppShell but want the same top bar.
  • Put the organization and project switchers in where, and the bell and the account menu in tools.

Do not use it when

  • Inside AppShell: it already has one.
  • Many buttons in the bar: keep it to search, notifications and the account.

For everyone

  • It is a header landmark.
  • Each tool has a name; the switchers say what they switch.

Props

TopBarTypeDefault
brandrequired ReactNode
tools ReactNode
where ReactNode
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
ProjectSwitcherTypeDefault
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
UserMenuTypeDefault
namerequired string
onSignOutrequired () => void
children

Items between the header and Sign out, as MenuItem: «Account», «Preferences».

ReactNode
email string
onAction ((key: Key) => void)
src string
NotificationBellTypeDefault
itemsrequired NotificationEntry[]
label

Defaults to «Notifications».

string
onOpen ((id: string) => void)
onReadAll (() => void)
  1. The bar of a console
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms