Ir al contenido

AppShell

El armazón de toda página con sesión: una barra superior que dice dónde estás, la navegación del área y el contenido. En el celular la navegación pasa abajo, con cinco elementos con nombre y «Más».

import { AppShell, Logo, CommandPalette } from '@sypnia/ui/react'

En esta página
  1. Una consola, en escritorio
  2. La misma consola, en un celular
  3. Skeleton
  4. Cuándo usarlo
  5. Para todos
  6. Props

Una consola, en escritorio

Esta es una página real hecha solo con piezas de la biblioteca. Presiona ⌘K o Ctrl K adentro, abre el menú de la cuenta, ordena la tabla.

La misma consola, en un celular

La navegación está abajo: cinco lugares con sus nombres y «Más» para el resto. La tabla se volvió tarjetas.

Código
import { useState } from 'react';
import {
  AppShell, Badge, Breadcrumb, Button, CommandPalette, IconButton, Logo, Menu, MenuItem, MenuSeparator, Page, PageHeader,
  Stat, StatGroup, Status, Table, Toaster, toast, useHotkey, useSypnia, type Column, type NavItem, type RenderLink,
} from '@sypnia/ui/react';

const nav: NavItem[] = [
  { href: '/project/shop', label: 'Overview', icon: 'home' },
  { href: '/project/shop/tables', label: 'Tables', icon: 'table' },
  { href: '/project/shop/sql', label: 'SQL', icon: 'query' },
  { href: '/project/shop/users', label: 'Users', icon: 'users' },
  { href: '/project/shop/keys', label: 'API keys', icon: 'key' },
  { href: '/project/shop/policies', label: 'Policies', icon: 'shield' },
  { href: '/project/shop/logs', label: 'Logs', icon: 'logs' },
  { href: '/project/shop/settings', label: 'Settings', icon: 'settings' },
  { href: '/account', label: 'Account', icon: 'user', foot: true },
  { href: 'https://data.docs.sypnia.com', label: 'Docs', icon: 'book-open', foot: true, external: true },
];

interface Row { name: string; rows: number; size: number; policies: number; updated: string }
const tables: Row[] = [
  { name: 'orders', rows: 18240, size: 9_437_184, policies: 3, updated: '2026-11-17T14:02:00Z' },
  { name: 'order_items', rows: 51873, size: 21_495_808, policies: 2, updated: '2026-11-17T14:02:00Z' },
  { name: 'customers', rows: 4310, size: 2_202_009, policies: 4, updated: '2026-11-16T09:41:00Z' },
  { name: 'products', rows: 126, size: 180_224, policies: 1, updated: '2026-11-12T18:20:00Z' },
  { name: 'refunds', rows: 0, size: 8192, policies: 0, updated: '2026-11-03T08:00:00Z' },
];

export default function Console() {
  const { format } = useSypnia();
  const [path, setPath] = useState('/project/shop/tables');
  const [palette, setPalette] = useState(false);
  useHotkey('k', () => setPalette((p) => !p));
  // In a real app this is the router's Link. Here a click only changes the current path.
  const link: RenderLink = ({ href, children, onClick, ...rest }) => (
    <a href={href} {...rest} onClick={(e) => { e.preventDefault(); setPath(href); onClick?.(); }}>{children}</a>
  );
  const columns: Column<Row>[] = [
    { id: 'name', header: 'Table', cell: (r) => <code>{r.name}</code>, sortValue: (r) => r.name },
    { id: 'rows', header: 'Rows', numeric: true, cell: (r) => format.number(r.rows), sortValue: (r) => r.rows },
    { id: 'size', header: 'Size', numeric: true, cell: (r) => format.bytes(r.size), sortValue: (r) => r.size },
    { id: 'policies', header: 'Access', cell: (r) => (r.policies ? <Badge tone="ok" dot>{r.policies} policies</Badge> : <Badge tone="warn" icon="warning">No policies</Badge>) },
    { id: 'updated', header: 'Last change', cell: (r) => format.relative(r.updated), sortValue: (r) => r.updated },
    { id: 'actions', header: 'Actions', actions: true, cell: (r) => <IconButton size="sm" icon="more" label={`Actions for ${r.name}`} /> },
  ];
  const title = nav.find((n) => n.href === path)?.label ?? 'Tables';
  return (
    <>
      <AppShell brand={<Logo product="Data" />} nav={nav} current={path} exact={['/project/shop']} renderLink={link} onSearch={() => setPalette(true)}
        where={<Breadcrumb items={[{ label: 'Acme', onClick: () => setPath('/project/shop') }, { label: 'shop' }]} />}
        tools={
          <Menu trigger={<IconButton icon="user" label="Account" variant="secondary" />}>
            <MenuItem icon="user" onAction={() => setPath('/account')}>Account</MenuItem>
            <MenuItem icon="globe">Español</MenuItem>
            <MenuSeparator />
            <MenuItem icon="sign-out">Sign out</MenuItem>
          </Menu>
        }>
        <Page>
          <PageHeader title={title} lead="Everything your app stores, as tables you can open, edit and protect."
            actions={<><Button icon="upload">Import CSV</Button><Button variant="primary" icon="plus" onClick={() => toast('Table created')}>New table</Button></>} />
          <StatGroup>
            <Stat label="Tables" value={format.number(tables.length)} />
            <Stat label="Rows" value={format.compact(74549)} delta="+1,204 today" trend="good" />
            <Stat label="Storage" value="31.8" unit="MB" delta="6% of your plan" />
            <Stat label="Database" value={<Status tone="ok" live>Healthy</Status>} />
          </StatGroup>
          <Table label="Tables" columns={columns} rows={tables} rowKey={(r) => r.name} />
        </Page>
      </AppShell>
      <CommandPalette open={palette} onClose={() => setPalette(false)}
        commands={[
          ...nav.filter((n) => !n.external).map((n) => ({ id: n.href, label: n.label, icon: n.icon, group: 'Go to', hint: 'shop', onSelect: () => setPath(n.href) })),
          { id: 'new-table', label: 'New table', icon: 'plus' as const, group: 'Do', onSelect: () => toast('Table created') },
          { id: 'invite', label: 'Invite a teammate', icon: 'user-plus' as const, group: 'Do', onSelect: () => toast('Invitation sent') },
        ]} />
      <Toaster />
    </>
  );
}

Skeleton

La misma consola antes de conocer la sesión: el marco, la navegación y la página como skeletons, a su tamaño real.

Código
import { AppShellSkeleton, BreadcrumbSkeleton, ChartSkeleton, FormSectionSkeleton, Page, TabsSkeleton } from '@sypnia/ui/react';

// The first paint of a console, before the session says which project and which items: the frame and the page are
// skeletons at their real sizes, so nothing moves when the real ones arrive.
export default function ShellSkeleton() {
  return (
    <AppShellSkeleton items={8}>
      <Page>
        <div className="sy-stack">
          <BreadcrumbSkeleton items={2} />
          <TabsSkeleton items={3} />
          <ChartSkeleton height={200} legend={2} />
          <FormSectionSkeleton fields={2} />
        </div>
      </Page>
    </AppShellSkeleton>
  );
}

Cuándo usarlo

Úsalo cuando

  • Cada página de una consola, detrás del inicio de sesión. Un armazón por app, para que todas las consolas de Sypnia se sientan como el mismo lugar.
  • La navegación tiene hasta cinco lugares principales. Más de cinco también funciona: el resto va en «Más» en el celular.

No lo uses cuando

  • Páginas antes del inicio de sesión (entrar, registrarse, primeros pasos): tienen su propio armazón, más simple.
  • Documentación y páginas de inicio: usan las piezas de documentación y de sitio.
  • Quieres una segunda barra lateral o un encabezado propio: pídelo aquí primero, para que lo tengan todas las consolas.

Para todos

  • La primera parada de Tab es «Saltar al contenido», que lleva el foco más allá de la navegación.
  • La barra superior, la navegación y el contenido son regiones (header, nav, main), cada una con nombre.
  • El lugar actual se marca con aria-current="page" y con la luz, nunca solo con color.
  • En el celular cada elemento de la barra inferior tiene su nombre debajo del icono y mide al menos 56 px de alto.
  • El botón de búsqueda dice su atajo como lo va a presionar esta persona: ⌘ K en teclados de Apple, Ctrl K en los demás.

Props

AppShellTipoPor defecto
brandobligatorio

The logo, usually <Logo product="Data" />.

ReactNode
currentobligatorio

The href of the current place. An item is current when this equals its href or starts with it followed by «/».

string
navobligatorio

The navigation of this area. On phones the first five show at the bottom with their names; the rest go under «More».

NavItem[]
banner

A message about the whole app, above everything.

ReactNode
brandHref string /
brandLabel string Sypnia
exact

Hrefs that are current only on an exact match (an «Overview» at the root of a section).

string[] []
onSearch

Shows the search button with its shortcut; it should open a CommandPalette.

(() => void)
renderLink RenderLink ({ children, ...p }) => <a {...p}>{children}</a>
tools

Right side of the top bar: account menu, notifications.

ReactNode
where

Where the person is: usually a Breadcrumb with the organization and project switchers.

ReactNode
LogoTipoPor defecto
product string
CommandPaletteTipoPor defecto
commandsobligatorio Command[]
onCloseobligatorio () => void
openobligatorio boolean
placeholder string
  1. Una consola, en escritorio
  2. La misma consola, en un celular
  3. Skeleton
  4. Cuándo usarlo
  5. Para todos
  6. Props

    Busca páginas, secciones y términos