Ir al contenido

Badge

Una etiqueta pequeña junto a una cosa que dice su estado o tipo en una palabra: Pagado, Borrador, Privado.

import { Badge, BadgeSkeleton } from '@sypnia/ui/react'

En esta página
  1. Tonos
  2. Punto, icono y contorno
  3. Junto a una cosa
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

Tonos

Neutro, información, éxito, advertencia, falla y el iluminado.

DraftIn reviewPaidPendingRefundedNew
Código
import { Badge } from '@sypnia/ui/react';

export default function Tones() {
  return (
    <div className="sy-row">
      <Badge>Draft</Badge>
      <Badge tone="info">In review</Badge>
      <Badge tone="ok">Paid</Badge>
      <Badge tone="warn">Pending</Badge>
      <Badge tone="fail">Refunded</Badge>
      <Badge tone="light">New</Badge>
    </div>
  );
}

Punto, icono y contorno

Una segunda señal además del color, y un contorno más discreto.

ActivePausedPrivatePublicRead onlySecret key
Código
import { Badge } from '@sypnia/ui/react';

// A dot or an icon gives a second sign besides the colour.
export default function Shapes() {
  return (
    <div className="sy-row">
      <Badge tone="ok" dot>Active</Badge>
      <Badge tone="warn" dot>Paused</Badge>
      <Badge icon="lock">Private</Badge>
      <Badge icon="globe" tone="info">Public</Badge>
      <Badge outline>Read only</Badge>
      <Badge outline icon="key">Secret key</Badge>
    </div>
  );
}

Junto a una cosa

El tipo al lado del nombre, el estado al final de la fila.

API keys

Back officeSecretActive
Mobile appPublicActive
Old websitePublicRevoked
Código
import { Badge, Panel } from '@sypnia/ui/react';

const keys = [['Back office', 'Secret', 'ok', 'Active'], ['Mobile app', 'Public', 'ok', 'Active'], ['Old website', 'Public', 'fail', 'Revoked']] as const;
export default function NextToAThing() {
  return (
    <Panel title="API keys">
      <div className="sy-stack">
        {keys.map(([name, kind, tone, state]) => (
          <div key={name} className="sy-row sy-row--between">
            <span className="sy-row"><span className="sy-text--sm sy-text--strong">{name}</span><Badge outline>{kind}</Badge></span>
            <Badge tone={tone} dot>{state}</Badge>
          </div>
        ))}
      </div>
    </Panel>
  );
}

Skeleton

La pieza real y su skeleton: la misma caja, así nada se mueve cuando llegan los datos.

PaidDraft
Código
import { Badge, BadgeSkeleton } from '@sypnia/ui/react';

// The state of a thing, before and after it is known. The skeleton has the same box as the real one, so nothing moves when the data arrives.
export default function Skeleton() {
  return (
    <div className="sy-row">
      <Badge tone="ok" dot>Paid</Badge><BadgeSkeleton dot />
      <Badge>Draft</Badge><BadgeSkeleton />
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Una fila, una tarjeta o un título tiene un estado que vale la pena ver de un vistazo.
  • La palabra es corta (una o dos) y sale de un conjunto conocido.
  • Agrega dot o un icono cuando aparecen varios tonos juntos, para que se distingan por algo más que el color.

No lo uses cuando

  • Se puede presionar, quitar o elegir: eso es un Chip.
  • Muestra un número: Count.
  • Dice si un servicio funciona ahora mismo: Status.
  • Tendría una frase. Una insignia que pasa de línea es una Alert disfrazada.

Para todos

  • Es texto simple: los lectores de pantalla leen la palabra en su lugar. El significado está en la palabra, nunca solo en el color.
  • Cada tono mantiene contraste AA en noche y papel.
  • No recibe foco ni tiene rol: nunca parece que se pudiera presionar.

Props

BadgeTipoPor defecto
className string
dot 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"
outline boolean
tone "light" | "info" | "ok" | "warn" | "fail" | "neutral" neutral
BadgeSkeletonTipoPor defecto
dot boolean
  1. Tonos
  2. Punto, icono y contorno
  3. Junto a una cosa
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

    Busca páginas, secciones y términos