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
Props
| 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
- apps/web/src/pages/dev/kit.astro ×35
- apps/web/src/pages/dev/kit/handoff.astro ×23
- packages/cms-blocks/src/renderers/parts/LeadForm.astro ×6
- apps/web/src/sections/blog/BlogFilters.astro ×4
- apps/web/src/sections/listings/ListingsResultsBar.astro ×3
- apps/web/src/components/NotFoundPage.astro ×2
- apps/web/src/layouts/chrome/menu/MenuBottombar.astro ×2
- apps/web/src/layouts/chrome/menu/MenuTopbar.astro ×2
- apps/web/src/layouts/chrome/Nav.astro ×2
- apps/web/src/pages/careers/[slug].astro ×2
- apps/web/src/pages/dev/kit/forms.astro ×2
- apps/web/src/sections/blog/PostGrid.astro ×2
- apps/web/src/sections/listing/ListingShare.astro ×2
- packages/cms-blocks/src/renderers/LandingFaq.astro ×2
- packages/cms-blocks/src/renderers/MediaCollage/orbital.astro ×2
- apps/web/src/layouts/chrome/Footer.astro ×1
- apps/web/src/layouts/chrome/LandingDock.astro ×1
- apps/web/src/layouts/chrome/LandingMenu.astro ×1
- apps/web/src/pages/careers.astro ×1
- apps/web/src/pages/dev/kit/media.astro ×1
- apps/web/src/pages/index.astro ×1
- apps/web/src/sections/blog/PostBody.astro ×1
- apps/web/src/sections/careers/OpenApplication.astro ×1
- apps/web/src/sections/faqs/FaqCategoryCard.astro ×1
- apps/web/src/sections/faqs/FaqCategoryPanel.astro ×1
- apps/web/src/sections/faqs/FaqHelp.astro ×1
- apps/web/src/sections/listing/ListingHighlights.astro ×1
- apps/web/src/sections/listing/ListingStickyBar.astro ×1
- apps/web/src/sections/listings/FilterSegment.astro ×1
- apps/web/src/sections/listings/ListingsGrid.astro ×1
- apps/web/src/sections/listings/ListingsHeader.astro ×1
- apps/web/src/sections/press/PressHero.astro ×1
- packages/cms-blocks/src/renderers/Chapter/story.astro ×1
- packages/cms-blocks/src/renderers/Hero/image.astro ×1
- packages/cms-blocks/src/renderers/Hero/textOverMedia.astro ×1
- packages/cms-blocks/src/renderers/HomeShowcase/Slide.astro ×1
- packages/cms-blocks/src/renderers/LandingFeatures.astro ×1
- packages/cms-blocks/src/renderers/MediaCollage/catalog.astro ×1
- packages/cms-blocks/src/renderers/MediaCollage/drift.astro ×1
- packages/cms-blocks/src/renderers/parts/LandingForm.astro ×1
- packages/cms-blocks/src/renderers/parts/LeadDialog.astro ×1
- packages/cms-blocks/src/renderers/SplitFeature.astro ×1
- packages/cms-blocks/src/renderers/Statement/cta.astro ×1
- packages/cms-blocks/src/renderers/StepPanel/parts/StepHeader.astro ×1