Ir al contenido

ErrorState

Lo que muestra una región cuando su contenido no se pudo cargar: qué pasó, en palabras simples, y un botón para intentar de nuevo.

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

En esta página
  1. Una región que falló
  2. Una página completa
  3. Sin permiso
  4. Cuándo usarlo
  5. Para todos
  6. Props

Una región que falló

Presiona «Try again»: el botón funciona y llega el contenido.

Usage this month

Código
import { useState } from 'react';
import { Button, EmptyState, KeyValue, Panel } from '@sypnia/ui/react';

// Press «Try again»: the region loads and shows its content.
export default function Region() {
  const [state, setState] = useState<'failed' | 'trying' | 'ready'>('failed');
  const retry = () => { setState('trying'); setTimeout(() => setState('ready'), 1800); };
  return (
    <Panel title="Usage this month" actions={state === 'ready' && <Button size="sm" onClick={() => setState('failed')}>Fail again</Button>}>
      {state === 'ready'
        ? <KeyValue items={[['Requests', '482,110'], ['Storage', '3.1 GB of 5 GB'], ['Team', '4 of 5 members']]} />
        : (
          <EmptyState tone="fail" compact title="The usage could not be loaded"
            actions={<Button busy={state === 'trying'} onClick={retry}>{state === 'trying' ? 'Loading…' : 'Try again'}</Button>}>
            The server took too long to answer. Your data is safe.
          </EmptyState>
        )}
    </Panel>
  );
}

Una página completa

Qué pasó, quién lo hizo y dos salidas.

Código
import { Button, EmptyState } from '@sypnia/ui/react';

// When the whole view fails: what happened, what the person can do, and a way out.
export default function WholePage() {
  return (
    <EmptyState tone="fail" title="This table no longer exists"
      actions={<><Button variant="primary" href="#">See all tables</Button><Button href="#">Open the activity log</Button></>}>
      <span className="sy-machine">order_drafts</span> was deleted by Diego Ruiz on November 12. Its rows are in the backups for 7 more days.
    </EmptyState>
  );
}

Sin permiso

Un candado dice más que la marca de error general.

Código
import { Button, EmptyState } from '@sypnia/ui/react';

// Another icon when it says more than the general one: here, a lock.
export default function OwnIcon() {
  return (
    <EmptyState tone="fail" icon="lock" title="You cannot see the billing of this project" actions={<Button icon="mail">Ask the owner</Button>}>
      Only the owner, Laura Méndez, can open it.
    </EmptyState>
  );
}

Cuándo usarlo

Úsalo cuando

  • Un panel, una tabla o una página no cargó.
  • Da siempre una forma de seguir: intentar de nuevo, ir a algo que funciona o pedirle a alguien.
  • Di si los datos de la persona están a salvo cuando pueda preocuparse.

No lo uses cuando

  • Falló una acción (guardar, borrar) y el contenido sigue en pantalla: Alert, junto a la acción.
  • Un campo está mal: el error va en su Field.
  • Simplemente no hay nada todavía: ese es el EmptyState normal.

Para todos

  • Se anuncia de inmediato (role="alert"), porque la persona esperaba un contenido que no va a llegar.
  • El icono cambia a la marca de error y el anillo se pone rojo; el título lleva el significado en palabras.
  • No muestres códigos de error solos. Si un código ayuda a soporte, ponlo después de la explicación.

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. Una región que falló
  2. Una página completa
  3. Sin permiso
  4. Cuándo usarlo
  5. Para todos
  6. Props

    Busca páginas, secciones y términos