Ir al contenido

IconButton

Un botón que muestra solo un icono, para acciones que la gente repite tanto que la imagen basta. Siempre tiene nombre: aparece al pasar y al enfocar, y es lo que dice un lector de pantalla.

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

En esta página
  1. Acciones sobre una cosa
  2. Tamaños y variantes
  3. Estados
  4. Cuándo usarlo
  5. Para todos
  6. Props

Acciones sobre una cosa

Cada icono dice su nombre al pasar y al enfocar. El destructivo es rojo y va de último.

Código
import { IconButton } from '@sypnia/ui/react';

// Rest the pointer on one, or reach it with Tab: its name appears.
export default function RowActions() {
  return (
    <div className="sy-row">
      <IconButton icon="edit" label="Rename table" />
      <IconButton icon="copy" label="Copy table ID" />
      <IconButton icon="download" label="Export as CSV" />
      <IconButton icon="trash" label="Delete table" variant="danger-quiet" />
    </div>
  );
}

Tamaños y variantes

Los mismos tres tamaños y variantes que Button. Discreto es lo normal.

Código
import { IconButton } from '@sypnia/ui/react';

export default function SizesAndVariants() {
  return (
    <div className="sy-row">
      <IconButton size="sm" icon="filter" label="Filter rows" />
      <IconButton icon="filter" label="Filter rows" />
      <IconButton size="lg" icon="filter" label="Filter rows" />
      <IconButton variant="secondary" icon="plus" label="Add column" />
      <IconButton variant="primary" icon="plus" label="New row" />
    </div>
  );
}

Estados

Uno que queda presionado, uno ocupado (presiónalo) y uno desactivado.

Código
import { useState } from 'react';
import { IconButton } from '@sypnia/ui/react';

export default function States() {
  const [starred, setStarred] = useState(false);
  const [busy, setBusy] = useState(false);
  const refresh = () => { setBusy(true); setTimeout(() => setBusy(false), 2000); };
  return (
    <div className="sy-row">
      <IconButton icon="star" label={starred ? 'Remove from favourites' : 'Add to favourites'} aria-pressed={starred}
        variant={starred ? 'secondary' : 'quiet'} onClick={() => setStarred((s) => !s)} />
      <IconButton variant="secondary" icon="download" label={busy ? 'Exporting…' : 'Export as CSV'} busy={busy} onClick={refresh} />
      <IconButton icon="trash" label="Delete table" disabled />
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • El espacio es poco y la acción es conocida: editar, copiar, borrar, cerrar, filtrar.
  • La misma acción se repite en cada fila de una tabla o una lista.
  • Enciende y apaga algo: pasa aria-pressed y cambia la etiqueta para decir qué hará al presionarlo.

No lo uses cuando

  • Es la acción principal de la superficie: usa un Button con palabras.
  • Habría que explicar el icono. Si la gente tiene que adivinar, escribe la etiqueta.
  • La acción destruye algo y está sola: «Borrar proyecto» en palabras es más seguro que una papelera.

Para todos

  • label es obligatorio: es el nombre accesible y la pista. La pista aparece al pasar y con el foco del teclado, y Escape la oculta.
  • Enter y Espacio lo presionan. En pantallas táctiles nunca mide menos de 44 px.
  • Un botón de alternar anuncia «presionado» o «no presionado» con aria-pressed.
  • Usa tooltip={false} solo cuando las mismas palabras ya se ven justo al lado.

Props

IconButtonTipoPor defecto
iconobligatorio "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"
labelobligatorio

What the button does. It is its accessible name and its tooltip: an icon alone is never enough.

string
busy

The action is running: the button stays focusable, does not fire again and shows a band of light. Change the label too («Saving…»).

boolean
className string
disabled boolean
href

Renders a link that looks like a button.

string
onClick

**Not recommended – use `onPress` instead.** `onClick` is an alias for `onPress` provided for compatibility with other libraries. `onPress` provides additional event details for non-mouse interactions.

(() => void)
size "sm" | "md" | "lg"
target string
tooltip

Set false when the name is already visible right next to it.

boolean true
variant

primary: the one main action of a surface. secondary: the alternative. quiet: tertiary. danger: cannot be undone.

"primary" | "secondary" | "quiet" | "danger" | "danger-quiet" quiet
  1. Acciones sobre una cosa
  2. Tamaños y variantes
  3. Estados
  4. Cuándo usarlo
  5. Para todos
  6. Props

    Busca páginas, secciones y términos