Ir al contenido

EmptyWithNextStep

Una página vacía es el comienzo de algo: dice qué vivirá aquí, da lo primero que hay que hacer y muestra las otras formas de entrar. Nada aún, nada que coincida, nada que puedas agregar: tres mensajes distintos.

import { EmptyState } from '@sypnia/ui/react'

En esta página
  1. En un computador
  2. En un celular
  3. Nada coincide
  4. Nada que puedas agregar
  5. Skeleton
  6. Cuándo usarlo
  7. Para todos
  8. Props

En un computador

Nada aún: para qué es una tabla, el primer paso y otras tres formas de entrar.

Tablas

Todo lo que guarda este proyecto, en tablas.

Aquí va tu primera tabla

Una tabla es donde tu app guarda un tipo de cosa: pedidos, clientes, eventos. Cada tabla tiene una API al instante.

Otras formas de empezar

orders.sql
create table orders (
  id bigint primary key generated always as identity,
  customer text not null,
  total numeric(10,2),
  created_at timestamptz default now()
);
Código
import { useState, type ReactNode } from 'react';
import {
  Button, Card, CodeBlock, EmptyState, Grid, Page, PageHeader, Panel, SearchInput, Section, SkeletonOf, SkeletonWords, Table,
  Toolbar, useSypnia,
} from '@sypnia/ui/react';

// An empty page is the start of something: it says what will live here, gives the one thing to do first, and the
// other ways in. Three kinds of empty: nothing yet, nothing that matches a search, and nothing you are allowed to add.
const en = {
  page: 'Tables', lead: 'Everything this project keeps, as tables.', create: 'Create a table',
  firstTitle: 'Your first table goes here', firstBody: 'A table is where your app keeps one kind of thing: orders, customers, events. Every table gets an API at once.',
  import: 'Import a CSV', ways: 'Other ways to start',
  template: 'Start from a template', templateText: 'Orders, customers, a blog: tables with their columns ready.',
  code: 'From code', codeText: 'Create tables with SQL or the SDK, and they appear here.',
  agent: 'With your coding agent', agentText: 'Connect Claude Code or Cursor and ask it for the table you need.',
  search: 'Search tables', noMatch: (q: string) => `No table is called «${q}»`, noMatchBody: 'Check the spelling, or search for part of the name.', clear: 'Clear the search',
  readTitle: 'No tables yet', readBody: 'You can read this project, but only its owners can create tables. Ask one of them, or ask for edit access.',
  ask: 'Ask for edit access', asked: 'Request sent to the owners',
  name: 'Name', rows: 'Rows',
};
const es: typeof en = {
  page: 'Tablas', lead: 'Todo lo que guarda este proyecto, en tablas.', create: 'Crear una tabla',
  firstTitle: 'Aquí va tu primera tabla', firstBody: 'Una tabla es donde tu app guarda un tipo de cosa: pedidos, clientes, eventos. Cada tabla tiene una API al instante.',
  import: 'Importar un CSV', ways: 'Otras formas de empezar',
  template: 'Empezar con una plantilla', templateText: 'Pedidos, clientes, un blog: tablas con sus columnas listas.',
  code: 'Desde el código', codeText: 'Crea tablas con SQL o con el SDK, y aparecen aquí.',
  agent: 'Con tu agente de código', agentText: 'Conecta Claude Code o Cursor y pídele la tabla que necesitas.',
  search: 'Buscar tablas', noMatch: (q: string) => `Ninguna tabla se llama «${q}»`, noMatchBody: 'Revisa cómo se escribe, o busca una parte del nombre.', clear: 'Borrar la búsqueda',
  readTitle: 'Aún no hay tablas', readBody: 'Puedes ver este proyecto, pero solo sus dueños pueden crear tablas. Pídeselo a uno de ellos, o pide permiso para editar.',
  ask: 'Pedir permiso para editar', asked: 'Solicitud enviada a los dueños',
  name: 'Nombre', rows: 'Filas',
};
const sql = `create table orders (\n  id bigint primary key generated always as identity,\n  customer text not null,\n  total numeric(10,2),\n  created_at timestamptz default now()\n);`;
const tables = [{ name: 'orders', rows: 1240 }, { name: 'customers', rows: 312 }, { name: 'invoices', rows: 988 }];

export default function EmptyWithNextStep({ state = 'first' }: { state?: 'first' | 'search' | 'read-only' | 'loading' }) {
  const { locale, format } = useSypnia();
  const c = locale.startsWith('es') ? es : en;
  const [query, setQuery] = useState(state === 'search' ? 'ordrs' : '');
  const [asked, setAsked] = useState(false);
  // Loading: before the app knows whether there are tables, the page draws what it showed last time (here: nothing
  // yet) with every word and button as a skeleton of its own box, so nothing moves when the answer comes.
  const loading = state === 'loading';
  const words = (n: ReactNode) => (loading ? <SkeletonWords>{n}</SkeletonWords> : n);
  const wait = (n: ReactNode) => (loading ? <SkeletonOf>{n}</SkeletonOf> : n);
  if (state === 'search') {
    const shown = tables.filter((t) => t.name.includes(query.trim().toLowerCase()));
    return (
      <Page>
        <PageHeader title={c.page} lead={c.lead} actions={<Button variant="primary" icon="plus">{c.create}</Button>} />
        <Table label={c.page} rows={shown} rowKey={(r) => r.name}
          toolbar={<Toolbar label={c.search} start><SearchInput aria-label={c.search} value={query} onChange={(e) => setQuery(e.target.value)} /></Toolbar>}
          columns={[{ id: 'name', header: c.name, cell: (r) => r.name }, { id: 'rows', header: c.rows, numeric: true, cell: (r) => format.number(r.rows) }]}
          empty={<EmptyState icon="search" compact title={c.noMatch(query)} actions={<Button onClick={() => setQuery('')}>{c.clear}</Button>}>{c.noMatchBody}</EmptyState>} />
      </Page>
    );
  }
  if (state === 'read-only') {
    return (
      <Page>
        <PageHeader title={c.page} lead={c.lead} />
        <Panel>
          <EmptyState icon="lock" title={c.readTitle} actions={<Button icon={asked ? 'check' : 'send'} disabled={asked} onClick={() => setAsked(true)}>{asked ? c.asked : c.ask}</Button>}>{c.readBody}</EmptyState>
        </Panel>
      </Page>
    );
  }
  return (
    <Page>
      <PageHeader title={c.page} lead={c.lead} />
      <Panel>
        <EmptyState icon="table" title={words(c.firstTitle)}
          actions={wait(<><Button variant="primary" icon="plus">{c.create}</Button><Button icon="upload">{c.import}</Button></>)}>
          {words(c.firstBody)}
        </EmptyState>
      </Panel>
      <Section title={words(c.ways)}>
        <Grid min="16rem">
          {wait(<Card title={c.template} href="#templates">{c.templateText}</Card>)}
          {wait(<Card title={c.agent} href="#connect-agent">{c.agentText}</Card>)}
          {wait(<Card title={c.code} href="#docs-sql">{c.codeText}</Card>)}
        </Grid>
        {wait(<CodeBlock code={sql} lang="sql" title="orders.sql" />)}
      </Section>
    </Page>
  );
}

En un celular

A 390 px las formas de entrar se apilan y los botones comparten el ancho.

Nada coincide

La tabla se queda con su búsqueda; el mensaje dice qué se buscó y ofrece borrarla. Prueba otra palabra.

Tablas

Todo lo que guarda este proyecto, en tablas.

Ninguna tabla se llama «ordrs»

Revisa cómo se escribe, o busca una parte del nombre.

Nada que puedas agregar

Para alguien que puede ver el proyecto pero no cambiarlo.

Tablas

Todo lo que guarda este proyecto, en tablas.

Aún no hay tablas

Puedes ver este proyecto, pero solo sus dueños pueden crear tablas. Pídeselo a uno de ellos, o pide permiso para editar.

Skeleton

Antes de saber si hay tablas: lo que mostró la última vez (nada todavía), cada palabra y cada botón como skeleton de su propia caja.

Tablas

Todo lo que guarda este proyecto, en tablas.

Cuándo usarlo

Úsalo cuando

  • La primera visita a cualquier lista: tablas, llaves, miembros, despliegues.
  • Una búsqueda o un filtro sin resultados: di qué se buscó y ofrece borrarlo.
  • Alguien que puede ver pero no crear: di quién puede, y cómo pedirlo.

No lo uses cuando

  • «Sin datos» sin nada que hacer.
  • El mismo mensaje para «nada aún» y «nada coincide»: uno invita a crear, el otro a buscar de nuevo.
  • Más de un botón principal: un primer paso, el resto secundarios.

Para todos

  • El mensaje vacío está donde estaría la lista, así se encuentra en el mismo lugar.
  • Cada forma de entrar es un enlace o un botón que dice lo que hace: «Crear una tabla», «Importar un CSV».

Props

EmptyStateTipoPor defecto
titleobligatorio

What this place is for, in one sentence of plain language.

ReactNode
actions

The one button that fills it, and at most one alternative.

ReactNode
compact boolean
icon "function" | "error" | "replay" | "performance" | "uptime" | "traces" | "rage-click" | "dead-click" | "alert" | "summary" | "watch" | "sleep" | "light" | "suggestion" | "prompt" | "mcp" | "pull-request" | "git-branch" | "fix" | "check" | "open-source" | "self-host" | "sdk" | "engine" | "signals-in" | "web" | "mobile" | "backend" | "cloud" | "data" | "user" | "clock" | "shield" | "lock" | "mail" | "star" | "copy" | "arrow-right" | "arrow-up-right" | "chevron-down" | "plus" | "close" | "play" | "pause" | "search" | "info" | "warning" | "trash" | "menu" | "download" | "upload" | "filter" | "home" | "table" | "key" | "users" | "sun" | "moon" | "globe" | "sign-out" | "link" | "edit" | "calendar" | "chevron-left" | "chevron-right" | "chevron-up" | "minus" | "more" | "sort" | "arrow-left" | "arrow-up" | "arrow-down" | "arrow-down-right" | "arrow-down-left" | "arrow-up-left" | "swap" | "swap-vertical" | "chevrons-up-down" | "chevrons-left" | "chevrons-right" | "chevrons-down" | "chevrons-up" | "enter" | "undo" | "redo" | "refresh" | "expand" | "collapse" | "fullscreen" | "fullscreen-exit" | "move" | "grip" | "more-vertical" | "trend-up" | "trend-down" | "log-in" | "external" | "slash" | "equal" | "check-small" | "close-small" | "success" | "failure" | "help" | "plus-circle" | "minus-circle" | "ban" | "pending" | "dot" | "dot-off" | "bolt" | "flag" | "pin" | "bookmark" | "heart" | "thumbs-up" | "thumbs-down" | "sparkle" | "target" | "idea" | "award" | "crown" | "bell" | "bell-off" | "bug" | "fire" | "leaf" | "file" | "file-text" | "file-code" | "file-plus" | "file-check" | "file-table" | "file-lock" | "files" | "folder" | "folder-open" | "folder-plus" | "archive" | "clipboard" | "clipboard-check" | "paperclip" | "image" | "save" | "cloud-upload" | "cloud-download" | "cloud-off" | "import" | "export" | "share" | "inbox" | "send" | "box" | "layers" | "tag" | "hash" | "at" | "qr-code" | "book" | "book-open" | "notebook" | "rows" | "columns" | "grid" | "list" | "list-ordered" | "list-checks" | "kanban" | "chart-line" | "chart-bar" | "chart-area" | "chart-parts" | "chart-scatter" | "gauge" | "funnel" | "heatmap" | "sparkline" | "percent" | "sum" | "variable" | "braces" | "brackets" | "null" | "primary-key" | "relation" | "index" | "query" | "backup" | "migrate" | "seed" | "csv" | "json" | "bold" | "italic" | "underline" | "strikethrough" | "heading" | "text" | "paragraph" | "quote" | "code" | "align-left" | "align-center" | "align-right" | "indent" | "outdent" | "unlink" | "scissors" | "eraser" | "highlight" | "duplicate" | "paste" | "wand" | "palette" | "brush" | "ruler" | "crop" | "user-plus" | "user-minus" | "user-check" | "user-x" | "user-circle" | "team" | "organization" | "id-card" | "contact" | "role" | "chat" | "chats" | "comment" | "phone" | "video" | "mic" | "mic-off" | "megaphone" | "rss" | "mail-open" | "handshake" | "wave" | "desktop" | "laptop" | "tablet" | "terminal" | "window" | "browser" | "server" | "cpu" | "memory" | "disk" | "network" | "wifi" | "wifi-off" | "plug" | "power" | "container" | "queue" | "cron" | "webhook" | "api" | "route" | "load-balancer" | "dns" | "domain" | "certificate" | "firewall" | "rocket" | "deploy" | "rollback" | "logs" | "test" | "pipeline" | "commit" | "merge" | "fork" | "release" | "environment" | "region" | "robot" | "agent" | "puzzle" | "credit-card" | "wallet" | "receipt" | "invoice" | "cart" | "bag" | "coins" | "dollar" | "gift" | "plan" | "upgrade" | "usage" | "bank" | "history" | "timer" | "hourglass" | "calendar-check" | "calendar-plus" | "map" | "compass" | "translate" | "accessibility" | "keyboard" | "pointer" | "hand" | "print" | "support" | "stop" | "record" | "skip-forward" | "skip-back" | "fast-forward" | "rewind" | "volume" | "mute" | "camera" | "zoom-in" | "zoom-out" | "eye-off" | "sliders" | "settings" | "toggle" | "sidebar-left" | "sidebar-right" | "panel-bottom" | "split" | "layout" | "dashboard" | "cards" | "density" | "dark-mode" | "theme" | "mouse" | "cursor" | "select" | "picture-in-picture" | "scan" | "unlock" | "shield-off" | "shield-alert" | "shield-user" | "password" | "fingerprint" | "two-factor" | "policy" | "incognito" | "verified" | "audit" | "secret" | "p-telemetry" | "p-cases" | "p-agent" | "p-git" | "p-data" | "p-files" | "p-run" | "p-ai" | "p-mail" | "p-domains" | "p-design" | "p-learn" | "p-skills" | "p-app" | "p-ui" light
tone "fail" | "neutral" neutral
  1. En un computador
  2. En un celular
  3. Nada coincide
  4. Nada que puedas agregar
  5. Skeleton
  6. Cuándo usarlo
  7. Para todos
  8. Props

    Busca páginas, secciones y términos