ComponentesComponents

BotónButton

Dispara una acción. Variantes primaria, contorno, secundaria, fantasma, peligro y enlace.Triggers an action. Primary, outline, secondary, ghost, destructive and link variants.

DiseñoDesign: coss ui (MIT) · button.tsxMITambos · densidaddensity baja · sobriaMarkdownJSON

CódigoCode

<div class="c-btn-row">
  <button class="c-btn c-btn--primary" type="button">Guardar</button>
  <button class="c-btn c-btn--outline" type="button">Cancelar</button>
  <button class="c-btn c-btn--secondary" type="button">Duplicar</button>
  <button class="c-btn c-btn--ghost" type="button">Omitir</button>
  <button class="c-btn c-btn--destructive" type="button">Eliminar</button>
  <a class="c-btn c-btn--link" href="#docs">Ver documentación</a>
</div>
<div class="c-btn-row">
  <button class="c-btn c-btn--outline" type="button">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 15V3"/><path d="m7 10 5 5 5-5"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/></svg>
    Descargar
  </button>
  <button class="c-btn c-btn--outline c-btn--icon" type="button" aria-label="Agregar">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
  </button>
  <button class="c-btn c-btn--primary" type="button" data-c-loading-demo>
    Publicar
    <svg class="c-btn__spinner" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
  </button>
  <button class="c-btn c-btn--primary" type="button" disabled>No disponible</button>
  <button class="c-btn c-btn--outline c-btn--sm" type="button">Pequeño</button>
  <button class="c-btn c-btn--outline c-btn--lg" type="button">Grande</button>
</div>
<p class="c-sr-only" role="status" data-c-btn-status></p>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Copia los archivos:Copy the files: button.html, button.css, button.js.
  3. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Para acciones en la página: guardar, abrir, copiar.
  • La variante enlace sirve para navegar con aspecto de botón de texto.
  • For on-page actions: save, open, copy.
  • The link variant navigates with a text-button look.

Mejor noAvoid

  • Para ir a otra página con aspecto de botón lleno: usa <a class="c-btn">.
  • Más de un primario por zona.
  • To navigate with a filled look: use <a class="c-btn">.
  • More than one primary per area.

AccesibilidadAccessibility

buttonlink
Enter EspacioActiva el botónActivates the button
  • Cargando usa data-loading y aria-disabled: conserva el foco y se anuncia en una región role=status.
  • En pantallas táctiles la zona de toque crece a 44 px sin cambiar el tamaño visible.
  • Un botón solo con icono lleva aria-label.
  • Loading uses data-loading and aria-disabled: focus stays and it is announced in a role=status region.
  • On touch screens the hit area grows to 44 px without changing the visible size.
  • Icon-only buttons carry aria-label.

Cómo probarloHow to test it

  • Pulsa «Publicar» con Espacio: el foco se queda y se anuncia «Publicado».
  • Press “Publish” with Space: focus stays and “Published” is announced.

CréditosCredits