Saltar al contenido
DS

Componentes · Acciones

Botón <Button>

El botón de VIVLA: cinco variantes sobre roles, así funciona igual en una banda clara, oscura o terracota.

import Button from '@vivla-cms/ds/primitives/Button.astro'

Ejemplos

Las seis variantes

primary es la acción principal (una por banda), secondary la acompaña, accent es el tipo Accent de Figma (terracota, texto blanco; también una por módulo), ghost es la terciaria, inverse va sobre fotos y pill es el chip de filtro. Cambia de tema abajo: los colores salen de los roles, ninguna variante tiene un caso por tema.

Estados, variante por variante

Reposo, deshabilitado y pulsado (solo pill). Pasa el ratón o tabula sobre la fila de reposo para ver el hover y el anillo de foco (2 px focus, separado 2 px). Deshabilitado usa los roles disabled / on-disabled / line-disabled, nunca una opacidad, y el botón no cambia de tamaño.

Reposo Deshabilitado Pulsado primary — secondary — ghost — inverse — pill

Con icono

Los slots leading y trailing llevan un <Icon> (decorativo: la etiqueta sigue siendo el nombre accesible). nudge desplaza el icono 4 px al pasar el ratón o al enfocar. size="icon" es el «Icon button» de Figma: un círculo de 56 px con un icono de 20, sin texto: necesita aria-label.

Enviar con flecha

ghost con underline={false}: el envío de los formularios (Figma 383:1522). Flecha de 36 px y el subrayado solo al pasar el ratón.

Filtros (pill)

Un chip pulsado se rellena con action y su texto se invierte: el estado no depende solo del color (sin check desde el hand-off del 30/10, como en Figma). El borde de 1 está en todos los estados, así que la fila no se mueve al pulsar. Con as="label" y un checkbox oculto, el filtro funciona sin JavaScript.

Tamaños

Components_Web dibuja UN tamaño: md, 54 px de alto (typography-02-M, Instrument Sans Medium 16/22, padding 32 × 16). landing-sm es el botón de la barra de las landings (42 px). sm es anterior a Foundations y solo vale para los chips de filtro compactos (/listings, /blog) y su panel; lg se retiró el 15/10 (ahora es md).

Sobre una foto

inverse invierte la superficie del tema: blanco sobre la foto oscura, y pasa a action-hover al pasar el ratón.

Como enlace, y con texto largo

Con href el botón es un <a> (los enlaces internos pasan por localizeHref). Si la etiqueta la escribe un editor en el CMS, pon wrap: una etiqueta de 30+ caracteres se saldría del relleno en un móvil.

Pastillas: línea, sin línea y quitar

La «Pill» de Components_Web (272:1055). pillStyle="line" (por defecto) es la de filtros y selección: borde de 1 en line-strong, 48 de alto. pillStyle="plain" es la de navegación: sin borde, 46 de alto. Elegida se rellena con action; al pasar el ratón, gris de marca (action-hover). Sin check: el relleno y el texto invertido ya marcan el estado. removable añade el aspa de 20 de los filtros aplicados (/listings) y «Quitar» delante del texto para los lectores de pantalla.

Props

Props de Button
Prop Valores Por defecto Para qué
variant primarysecondaryghostinversepillaccent 'primary' —
size smmdiconlandinglanding-sm 'md' md (default) = the Figma button (16 / 22, px 32 py 16, 54 px; Components_Web 20:2) · sm = the compact filter chips and their panel buttons (/listings, /blog) — no Foundations twin, ask design before using it anywhere else · icon = 56 px circular icon-only (needs aria-label) · landing = the same 52 px box (Landings Performance 158:5777) · landing-sm = its 42 px bar button (py 10 · 16/22, 158:5750)
pillStyle lineplain 'line' Pill only (Components_Web 272:1055): line (default) = «Línea», filters and selection, 1 px border, 48 px · plain = «Sin línea», navigation, no border, 46 px.
removable boolean false Pill only: Figma's «Icono cerrar» — a 20 px close glyph after the label, and «Quitar» / «Remove» before the label for screen readers. For an applied filter chip whose click removes it.
as 'label' — label renders a <label> for a checkbox pill (wrap a hidden checkbox).
href string — —
external boolean false Skip localizeHref (language toggle, outbound links).
locale string — Override the locale used by localizeHref; defaults to the current page.
type buttonsubmitreset 'button' —
target string — —
rel string — —
disabled boolean false —
underline boolean true Ghost only: false drops the resting underline (arrow submit); hover still underlines.
nudge boolean false Nudge the leading/trailing icon 4 px on hover and focus (motion-safe).
wrap boolean false Let a long label wrap inside the button instead of keeping it on one line. The button is whitespace-nowrap by default — the 2026 labels are two or three words and a wrapped CTA reads badly. But the label can come from the CMS: a 30+ character one spills out of the fill on a phone, because the box cannot grow. Pass wrap wherever an editor writes the label (statement · cta, ctaBanner); leave it off for fixed UI labels.
hidden boolean — Hide the button. Use THIS, never class="hidden": the button's own inline-flex is emitted AFTER Tailwind's .hidden in the stylesheet and both are one class of specificity, so class:list={[cond && 'hidden']} computes to display: inline-flex and the button stays on screen. The hidden ATTRIBUTE wins through preflight's [hidden]:where(:not([hidden="until-found"])) { display: none !important }. From a client script, set the property (el.hidden = …), not the class.
data-* string | undefined — Se pasan tal cual al elemento.
aria-* string | undefined — Se pasan tal cual al elemento.

Slots: leading · contenido · trailing

Notas del código

El comentario de cabecera de Button.astro, tal cual (en inglés, como el código): si cambia el código, cambia esto.

Figma Components_Web «Button» 19:2 (anatomy 20:2) plus the 2026 extras, over roles only, so the same markup works inside light, dark and accent sections. Figma: a Button triggers an action; navigation is Link, «Ver más →» is Link arrow; at most one primary or accent per module.

primary    action fill            (main CTA, one per section)
secondary  outlined line-strong   (paired with primary)
ghost      text + underline       (tertiary / inline actions)
           `underline={false}` is the arrow submit (Figma 383:1522/1523)
inverse    on-surface fill        (buttons over photos / dark media)
accent     action-accent fill     (Figma Accent: terracotta, white text)
pill       chip / filter toggle   (Figma «Pill» 272:1055; see "Pill")

Renders <a> when href is set. Internal hrefs go through localizeHref() (house rule) unless external is true. data-* / aria-* props pass through (e.g. data-track="cta_click", aria-haspopup="dialog").

Icons: named slots leading / trailing take an <Icon> (decorative, it is aria-hidden by default, so the label stays the accessible name). nudge moves the icons 4 px along the inline axis on hover and keyboard focus (motion-safe only), the arrow cue of the 2026 references.

<Button type="submit" variant="ghost" underline={false} nudge class="uppercase">
  <Icon slot="leading" name="arrow-right" size={36} />
  Enviar solicitud
</Button>

Icon-only: size="icon" is Figma's «Icon button» 151:255 — a 56 px circle holding a 20 px icon, one <Icon> in the default slot. Figma draws it in primary («se invierte con el modo»: black disc + white glyph on light, white disc + black glyph on dark; hover black/60, disabled k.30), so use variant="primary" — inverse paints the theme surface as the glyph, which on the grey light theme is k.10 grey, not white. It has no text, so pass aria-label (a dev warning fires without one). Icon-only toggles get no check glyph: swap the icon itself (play/pause, sound-on/off) as the non-colour cue.

<Button variant="primary" size="icon" aria-label={uiLabel('carouselNext', locale)}>
  <Icon name="arrow-right" size={20} />
</Button>

Pill (Components_Web «Pill · Tapbar» 272:1055, hand-off 1442:6432): a 100-radius chip, px 24 · py 12, label typography-02-M medium, gap space/4xs (4). Two styles, pillStyle:

line (default) «Línea» — filters and selection: a 1 px border in the
     layout (48 px tall), `line-strong` at rest as the hand-off draws it
     (Components_Web 272:1055 says border/default: revisable); selected
     and hover keep the border in the fill colour, so the box never moves.
plain «Sin línea» — navigation: no border (46 px tall).

Both: selected fills with action + on-action (the fill and the text inversion are the non-colour cue; no check glyph since 30/10, as in Figma), hover fills with action-hover + on-action-hover, focus is the global 2 px ring. removable adds Figma's «Icono cerrar» (line/close 20 after the label, same colour as the text) and prefixes the accessible name with «Quitar» / «Remove» (uiLabel('chipRemove')): an applied filter chip.

<Button variant="pill" removable data-filter="location">Asturias</Button>
<Button variant="pill" pillStyle="plain" href="#reservas" aria-current="location">Reservas</Button>

Pressed (pill): pass aria-pressed="true" | "false" on a <button> toggle, aria-current="page" on an <a> chip, aria-current="true" | "location" on an in-page anchor that tracks the scrolled section, or the legacy data-active="true".

Checkbox pill (filters in a GET form that work without JS): as="label" renders a <label>; put a visually hidden checkbox inside. The chip reads :checked (has-checked), draws the focus ring when the input has keyboard focus and takes the disabled roles when it is disabled.

<Button as="label" variant="pill">
  <input type="checkbox" name="location" value="ibiza" class="sr-only" checked />
  Ibiza
</Button>

Colours (Figma Foundations 107:427, action/*): the primary button is the action role — black with white text on light and paper, white with black text on dark, terracotta and cobalt — and hovers to action-hover (black/60) with on-action-hover (white). accent is Figma's Accent type: action-accent (terracotta) → action-accent-hover, text on-action-accent (white). Secondary is outlined in line-strong — a 1.5 px stroke drawn as an inset ring, as Figma strokes inside, so it is as tall as the filled button — and fills with action on hover. Disabled buttons use the disabled roles (filled: disabled fill + on-disabled text, no border — Figma 19:2 draws none since 30/10; outlined: transparent with the same text and the line-disabled border) instead of an opacity, and stop pointer events. Every theme resolves the roles itself, so no variant carries a per-theme override. Ratios per theme are printed on /dev/kit#button-contrast.

Focus: the global :focus-visible ring (2 px focus, offset 2 px — the Foundations FOCUS state 487:25 / 487:34 draws a 2 px border with a 2 px gap around the box), so a white ring never merges with a white fill. accent rings in action-accent-focus instead (Figma action/accent/border-focus: espresso on light, white on dark), not cobalt.

Shape and size (Components_Web 20:2): square corners (rounded-button = 0) and ONE size — label typography-02-M (Instrument Sans Medium 16 / 22), padding space/xs × space/m (16 × 32), gap space/3xs, icons 20: 54 px tall, «el alto resulta del texto». That is md (the default); landing is the same box. sm predates Foundations (compact filter chips only); lg was retired on 15/10 — use md.

Dónde se usa

120 veces en 44 archivos de la web y los bloques del CMS.

Ver los archivos
esc