Ir al contenido

TopBar

La barra de arriba de cada página con sesión iniciada: la marca, dónde está la persona y las herramientas a la derecha. AppShell la dibuja; úsala suelta cuando el marco es propio de la app.

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

En esta página
  1. La barra de una consola
  2. Cuándo usarlo
  3. Para todos
  4. Props

La barra de una consola

/
Código
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={() => {}} /></>} />
  );
}

Cuándo usarlo

Úsalo cuando

  • Apps que no usan AppShell pero quieren la misma barra superior.
  • Pon los selectores de organización y de proyecto en where, y la campana y el menú de la cuenta en tools.

No lo uses cuando

  • Dentro de AppShell: ya tiene una.
  • Muchos botones en la barra: déjala en buscar, notificaciones y la cuenta.

Para todos

  • Es una región header.
  • Cada herramienta tiene un nombre; los selectores dicen qué cambian.

Props

TopBarTipoPor defecto
brandobligatorio ReactNode
tools ReactNode
where ReactNode
OrgSwitcherTipoPor defecto
currentobligatorio string
onChangeobligatorio (id: string) => void
optionsobligatorio 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
ProjectSwitcherTipoPor defecto
currentobligatorio string
onChangeobligatorio (id: string) => void
optionsobligatorio 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
UserMenuTipoPor defecto
nameobligatorio string
onSignOutobligatorio () => void
children

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

ReactNode
email string
onAction ((key: Key) => void)
src string
NotificationBellTipoPor defecto
itemsobligatorio NotificationEntry[]
label

Defaults to «Notifications».

string
onOpen ((id: string) => void)
onReadAll (() => void)
  1. La barra de una consola
  2. Cuándo usarlo
  3. Para todos
  4. Props

    Busca páginas, secciones y términos