Ir al contenido

CheckboxCard

Un sí o no dibujado como tarjeta: un título, una frase sobre lo que hace y toda la tarjeta para presionar.

import { CheckboxCard, CheckboxCardSkeleton } from '@sypnia/ui/react'

En esta página
  1. Una opción con su explicación
  2. Varias bajo una pregunta
  3. Desactivado
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

Una opción con su explicación

Márcala: el texto debajo de la tarjeta dice qué va a pasar.

Without it, backups are made once a week.

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

export default function Basic() {
  const [daily, setDaily] = useState(false);
  return (
    <div className="sy-stack">
      <CheckboxCard label="Daily backups" description="A copy of the whole database every night at 03:00, kept for 30 days." icon="shield" checked={daily} onChange={setDaily} />
      <p className="sy-text--sm sy-text--muted">{daily ? 'Adds USD 5 a month. The first backup runs tonight.' : 'Without it, backups are made once a week.'}</p>
    </div>
  );
}

Varias bajo una pregunta

Tarjetas que no se excluyen, dentro de un Fieldset que nombra la pregunta.

Add-ons
Código
import { CheckboxCard, Fieldset } from '@sypnia/ui/react';

export default function Several() {
  return (
    <Fieldset legend="Add-ons">
      <div className="sy-grid">
        <CheckboxCard label="Point-in-time recovery" description="Go back to any second of the last 7 days." icon="clock" defaultChecked />
        <CheckboxCard label="Read replica" description="A second copy that answers queries, in another region." icon="copy" />
        <CheckboxCard label="Audit log" description="Who changed what, and when, kept for a year." icon="users" />
      </div>
    </Fieldset>
  );
}

Desactivado

Apagada y encendida. Una frase al lado dice por qué no se pueden cambiar.

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

export default function States() {
  return (
    <div className="sy-stack">
      <div className="sy-grid">
        <CheckboxCard disabled label="Audit log" description="Comes with the Team plan." />
        <CheckboxCard disabled defaultChecked label="Encryption at rest" description="Always on, in every plan." icon="lock" />
      </div>
    </div>
  );
}

Skeleton

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

Código
import type { CSSProperties } from 'react';
import { CheckboxCard, CheckboxCardSkeleton } from '@sypnia/ui/react';

// An option whose words are still loading. 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-grid" style={{ '--min': '16rem' } as CSSProperties}>
      <CheckboxCard label="Daily backups" description="Kept for 30 days." defaultChecked />
      <CheckboxCardSkeleton />
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Una opción que merece explicación antes de marcarla: un complemento, un consentimiento, una función con costo.
  • Unas pocas lado a lado, cuando varias pueden estar encendidas a la vez.

No lo uses cuando

  • La opción se entiende en pocas palabras: Checkbox.
  • Se aplica de inmediato en vez de guardarse con un formulario: Switch.
  • Solo se puede elegir una de las tarjetas: RadioCards.

Para todos

  • Es una casilla nativa dentro de una etiqueta: Espacio la marca, y presionar en cualquier parte de la tarjeta también.
  • Lee primero el título y luego la frase.
  • Encendida se nota por el borde, el tinte y la casilla marcada: nunca solo por el color.
  • Varias tarjetas sobre una misma pregunta van dentro de un Fieldset, así la pregunta se anuncia con cada una.

Props

CheckboxCardTipoPor defecto
labelobligatorio string
checked boolean
className string
defaultChecked boolean
description

What turning it on means, in a sentence.

string
disabled 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"
id

Inside a Field it comes from the Field.

string
name string
onChange ((checked: boolean) => void)
value string
  1. Una opción con su explicación
  2. Varias bajo una pregunta
  3. Desactivado
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

    Busca páginas, secciones y términos