Patrones
Tarjeta de casa <HomeCard>
La única tarjeta de casa de la web, en sus tres formas: cuadrícula, destacada y promoción.
import HomeCard from '@vivla-cms/cms-blocks/renderers/parts/HomeCard.astro'Ejemplos
Cuadrícula de casas
La tarjeta tile: foto cuadrada con el nombre encima y, debajo, el lugar, los datos y el precio por octavo. Toda la tarjeta es un enlace. En /listings van dos por fila en escritorio y una en móvil; cambia el ancho abajo para verlo. Los datos son los de vivla-tools (HomeSummary), nunca escritos a mano.
---
import HomeCard from '@vivla-cms/cms-blocks/renderers/parts/HomeCard.astro'
import Col from '@vivla-cms/ds/primitives/Col.astro'
import Columns from '@vivla-cms/ds/primitives/Columns.astro'
import Container from '@vivla-cms/ds/primitives/Container.astro'
import { devCardLabels, devHomeCases } from '@/lib/dev-home-card-fixtures'
const labels = devCardLabels('es')
const cases = devHomeCases({ origin: Astro.url, locale: 'es' }).slice(0, 4)
---
<Container width="wide">
<Columns gapY="stack">
{
cases.map((entry, i) => (
<Col mobile={4} tablet={4} desktop={6}>
<HomeCard home={entry.home} labels={labels} highlight={entry.highlight} locationLabel={entry.locationLabel} position={i} trackLabel="ds-ejemplo" eager={i < 2} />
</Col>
))
}
</Columns>
</Container> Todos los estados
Lo que una captura de la web casi nunca enseña: agotada (sin precio, nunca), cada etiqueta de estado (última fracción, en construcción), sin foto, precio a consultar sin datos, y nombres de una palabra o muy largos (el nombre se parte en dos líneas sobre la foto). La etiqueta de estado sale del estado de la casa en vivla-tools; la tarjeta no inventa ninguna.
---
import HomeCard from '@vivla-cms/cms-blocks/renderers/parts/HomeCard.astro'
import Col from '@vivla-cms/ds/primitives/Col.astro'
import Columns from '@vivla-cms/ds/primitives/Columns.astro'
import Container from '@vivla-cms/ds/primitives/Container.astro'
import Text from '@vivla-cms/ds/primitives/Text.astro'
import { devCardLabels, devHomeCases } from '@/lib/dev-home-card-fixtures'
const labels = devCardLabels('es')
const cases = devHomeCases({ origin: Astro.url, locale: 'es' })
---
<Container width="wide">
<Columns gapY="stack">
{
cases.map((entry, i) => (
<Col mobile={4} tablet={4} desktop={4} class="flex flex-col gap-3">
<Text size="small" tone="muted" weight="medium" class="uppercase">{entry.label}</Text>
<HomeCard
home={entry.home}
labels={labels}
showSoldOutBadge={entry.showSoldOutBadge}
highlight={entry.highlight}
locationLabel={entry.locationLabel}
position={i}
trackLabel="ds-ejemplo"
/>
</Col>
))
}
</Columns>
</Container> Casa destacada
variant="feature": foto 8/12 (proporción 6/5) y panel terracota 4/12 con la etiqueta y el nombre arriba y el lugar, los datos y lo que la hace única abajo. Sin precio, como en Figma. Móntala en una banda contenida (width="wide" o shell), nunca a sangre: a sangre se sale 40 px de la línea de la página por cada lado.
---
import HomeCard from '@vivla-cms/cms-blocks/renderers/parts/HomeCard.astro'
import Container from '@vivla-cms/ds/primitives/Container.astro'
import { devCardLabels, devFeaturedCase } from '@/lib/dev-home-card-fixtures'
const labels = devCardLabels('es')
const featured = devFeaturedCase({ origin: Astro.url, locale: 'es' })
---
<Container width="wide">
<HomeCard
variant="feature"
home={featured.home}
labels={labels}
locationLabel={featured.locationLabel}
highlight={featured.highlight}
trackLabel="ds-ejemplo"
/>
</Container> Tarjeta de promoción
variant="promo": la pieza editorial que se cuela en la cuadrícula de casas, en la misma caja cuadrada que una casa: ilustración, disco con flecha y una frase en serif. Lleva a contacto, no a una ficha.
---
import HomeCard from '@vivla-cms/cms-blocks/renderers/parts/HomeCard.astro'
import Col from '@vivla-cms/ds/primitives/Col.astro'
import Columns from '@vivla-cms/ds/primitives/Columns.astro'
import Container from '@vivla-cms/ds/primitives/Container.astro'
import { devCardLabels, devHomeCases, devPromoCase } from '@/lib/dev-home-card-fixtures'
const labels = devCardLabels('es')
const [first] = devHomeCases({ origin: Astro.url, locale: 'es' })
const promo = devPromoCase({ origin: Astro.url, locale: 'es' })
---
<Container width="wide">
<Columns>
<Col mobile={4} tablet={4} desktop={6}>
<HomeCard home={first.home} labels={labels} highlight={first.highlight} trackLabel="ds-ejemplo" />
</Col>
<Col mobile={4} tablet={4} desktop={6}>
<HomeCard variant="promo" title={promo.title} href={promo.href} image={promo.image} imageAlt={promo.imageAlt} position={1} trackLabel="ds-ejemplo" />
</Col>
</Columns>
</Container> Props
| Prop | Valores | Por defecto | Para qué |
|---|---|---|---|
| variant | tilefeaturepromo | — | — |
| home * | HomeSummary | — | — |
| labels * | HomeCardLabels | — | — |
| statusLabels | StatusBadgeLabels | — | Corner-pill copy. Defaults to defaultStatusBadgeLabels(locale);
/listings passes the listings-page.card.* strings instead. |
| flag | string | null | — | A second pill BEFORE the status one, e.g. «Destacada» on a destination's
featured home (/destinations/<slug>, guide featuredHome). Same
Badge, so the corner reads as one row of labels. |
| locationLabel | string | null | — | Overrides home.destinationName. |
| highlight | string | null | — | Overrides uniqueFeatures[0].label. |
| summary | string | null | — | Overrides home.cardSummary (a homeShowcase grid item's tagline). |
| designerName | string | null | — | Overrides home.designerName (a homeShowcase grid item's designer). |
| showPrice | boolean | — | false hides the price slot (the feature panel draws none, per Figma). |
| headingLevel | 23 | — | Heading level of the home name. Default 3 (tile) / 2 (feature). |
| position | number | — | 0-based position in its grid; the click reports item_position = this + 1. |
| trackLabel | string | — | data-track-label of the card_click event, e.g. listings-grid. |
| priority | boolean | — | The LCP card: eager + fetchpriority="high". Implies eager. |
| eager | boolean | — | Above the fold (the first three tiles): eager, no priority hint. |
| sizes | string | — | sizes for the photo; defaults to {@link HOME_CARD_SIZES}. |
| title * | string | — | Stored in sentence case; the card uppercases it in CSS. |
| href * | string | — | Already resolved by the route (resolveCardLink), e.g. #contact. |
| newTab | boolean | — | — |
| linkType | internalexternal | — | external when the href leaves vivla.com — only the tracking param. |
| image | MediaField | — | — |
| imageAlt | string | null | — | — |
| leadDialog | specswishcontactwaitlistnull | — | Opens a lead dialog instead of following href when the page mounts one
(data-lead-dialog-open, the lead-dialogs contract): /listings passes
wish («¿Qué casa buscas?»). The href stays the no-JS fallback. |
Notas del código
El comentario de cabecera de HomeCard.astro, tal cual (en inglés, como el código): si cambia el código, cambia esto.
the one home card of the 2026 site, in three variants. Figma Web 2026 DCZJOXXl9SZG4C0ByXRSew, page «Hand off» 1072:1380 (30/10/2026), /listings 1239:4854 (desktop) · 1444:12458 (phone):
tile «Card · stacked», Tipo=Estándar: Tamaño M `1556:3769` (706 wide,
media 706 × 744) and Tamaño S `1556:3771` (408 wide, media
408 × 432); instances `1237:4130` / `1436:2406`.
feature «Card · split» `1556:3733` (1431 × 804: photo 967 + panel 464);
phone `1436:2396` (photo 408 × 306 over the panel).
promo «Card · stacked», CTA variant `1239:4770` (706 × 744, no caption). A cms-blocks PART (18/09): routes mount it — /listings (tiles + featured + promo), /destinations/<slug> (rail), SimilarHomes on the ficha, the blog body's house card — and so does the homeShowcase block's grid layout. Every input is a prop and nothing is fetched here. The hand-off draws the card only on /listings; it is the one card everywhere (questions.md J12, revisable).
## M or S: the card's own width, not the viewport
tile and promo are a size container (@container): from 36rem (576 px) of card they draw Tamaño M (title typography-01-3XL 48/48, the facts row typography-02-M in content/tertiary, 16 under the place), below it Tamaño S (title typography-01-XL 32/34, facts typography-02-S in content/secondary, 12). So the 706 px /listings tile is M at 1512, a phone card is S, and a 464 px card in the three-across destination rail or the similar homes is S too, where a 48 px name would not fit next to its disc.
## Layout
Since the 04/11/2026 design meeting the card shows the house's real facts and the price, which has priority; the «Fracción» pie («la quesera», FractionPie) is gone. Desktop Tamaño M 1745:5708 (706 × 888, row 1239:4673 of /listings 1239:4854), phone Tamaño S 1745:6188 (408 × 570); split 1237:4156 (desktop) and 1436:2396 (phone).
tile — the photo under an even 20 % espresso veil (Figma draws 10 %; raised at the 05/11 review, see the markup), the arrow disc and the name over its bottom-left corner (padding space/m × space/l = 32 × 40), then the «Meta» block 32 below: the place (typography-01-L, uppercase), 16 (M) / 12 (S) under it the «Datos» row — [bed] 4 hab · [bath] 3 baños · [area] 228 m² · [pool] Piscina, 20 px line icons, 16 between items, 8 between an icon and its text (Figma 6, off the Foundations scale: snapped to space/3xs, the split card's value) — wrapping when a narrow card cannot hold it, and 16 under that the «Precio» row: the amount typography-02-XL regular (24/30), «por 1/8» typography-02-S medium, 4 apart, bottoms aligned. The facts and the ONE special feature are homeCardFacts() (rule: HOME_CARD_FEATURES); anything the house lacks is not drawn. The feature gets its own icon (pool, fireplace…) since 18/11 (Jaime); until then the tile drew Figma's diamond for every one.
The photo, the scrim and the overlay copy are cells of a ONE-CELL grid (col-start-1 row-start-1) rather than absolute layers, because the stretched link has to cover the WHOLE tile — caption included — and after:inset-0 resolves against the nearest positioned ancestor. The photo cell takes -z-10 (the isolate on the article keeps that layer inside the card). Status tags (Última fracción, En construcción…) are not drawn in the hand-off; they stay white, top-left (J38, revisable), in capitals like the split card's Tag (Jaime, 18/11: «todos los tags van en mayúscula»). Never «Agotada» (06/11/2026): a sold-out home keeps its price like any other, and since 18/11 wears «Lista de espera» (lib/home-card.ts).
feature — the photo beside a terracotta panel exactly four columns wide (Foundations Layout 768:48: 4 × 101 + 3 × 20 = 464 at 1512); the photo takes the rest (967). The panel is data-theme="accent-inverse" (white ink on surface/05, questions.md J3). As Jaime re-drew «Card · split» on 06/11 (desktop Tamaño=M, instance 1237:4156 of 1924:13771; phone 1436:2396):
desktop — the Tag (terracota-60, `Badge tone="soft"`, in capitals, 32 ×
12 padding) 108 from the top, the name typography-01-6XL 72/68 40 below
it; the «Ubicación» block sits at the FOOT, 64 above the bottom (it was
80 under the name): the place typography-01-XL 32/34 (was 01-L 24/28),
64, the facts as a list — typography-02-L 20/26 medium (was 02-M),
32 px icons (was 20), 16 between rows (was 8), 8 between icon and text,
the feature with ITS OWN icon — 64, the price.
phone — padding 40 · 24 · 80, the tag (16 × 12) and the name 01-4XL
56/55 32 apart, 80 to «Ubicación» (was 64); in it the place 01-L 24/28,
the facts (02-M 16/22, 32 px icons, 8 apart) and the price, 40 apart
(was 64).
the price, both — the amount typography-02-XL MEDIUM 24/30 (was
regular) and «por 1/8» 02-M 16/22 medium (was 02-S), 4 apart, bottoms
aligned. MOUNT IT IN A CONTAINED BAND, never <Section width="full">: Figma paints it inside the 1432 shell. Photo and panel share ONE box at every width (Jorge, 21/10): side by side the 967/804 ratio lives on an in-flow spacer and the photo fills the column absolutely, so a taller panel stretches the photo instead of hanging below. Below 1440 (90rem) the panel is narrower than Figma's 464 and its 1512 rhythm no longer fits the photo's height: the photo turned portrait (852 tall × 813 at 1280, 852 × 643 at 1024) and the crop zoomed into its centre — the «la cara se me queda enorme» of the 06/11 review on Laura's laptop. So from lg to 90rem the panel takes the PHONE split card's rhythm (1436:2396: name 01-4XL 56/55, 40 on top, 32 under the tag, the phone's facts and gaps), and below xl the gap above «Ubicación» and the foot close to 40: the photo keeps the 967/804 ratio down to 1280 and stretches far less below it (revisable).
promo — surface/05 with the white house sketch (the editor's image, featured-homes.promoCard.image) and the same disc + title as a tile. leadDialog adds data-lead-dialog-open so the page's dialog opens instead of following the link (the href stays the no-JS path).
Removed with the hand-off: the highlight, summary, designer, «x/8 vendidos» (and, on 04/11, the pie that drew it) and the visible «Ver la casa →» (the sr-only suffix of the link stays). The props are still accepted, so no caller breaks.
## Behaviour
One <a> per card, on the name, stretched over the article with after:inset-0: the accessible name is the home name, the card is one tab stop, and the ring the article draws with has-[a:focus-visible] traces the whole card in the card's own theme (on the tile the anchor sits in the dark photo scope, whose focus colour would fail 3:1 on the light page). Hover (06/11/2026, Laura: the card did not feel clickable; she asked for the cards of lucerostudio.es, Jaime's studio — «ese zoom me ha encantado», «el movimiento de la flecha también»), measured there with Playwright: the photo grows 16 px past each edge of its 721 × 692 frame (× 1.046, clipped) and the 56 px disc becomes 80 (× 1.43) while its arrow turns 45°, on one Framer spring (target reached at ≈ 240 ms, 16 % overshoot at ≈ 370 ms, settled ≈ 1 s). Here: the photo scale 1.046 inside its frame (the Media wrapper clips), the disc scale 1.43 from its bottom-left corner, the arrow rotate −45° (Figma draws it pointing right at rest, so it lifts to ↗ — Lucero turns ↗ into →), and the name slides 24 px right to keep its 16 px from the bigger disc. All on --duration-slow (600 ms) + --ease-out, the DS pair closest to that spring (90 % by ≈ 220 ms; the DS has no overshoot). motion-safe only (no movement with reduced motion), and Tailwind's hover only matches (hover: hover), so a tap never leaves a card stuck zoomed. Nothing scroll-driven.
Tracking: data-track="card_click" with track_label, item_title, item_position, link_type, home_slug and card_variant (lib/analytics.ts delegates on [data-track]).
The arrow disc is Foundations' «Icon button» 1416:4028 (56, line/ arrow-right 20, action fill that inverts with the mode) drawn as a span: the card's link is the one control, so a nested button would be a second tab stop for the same destination.
Dónde se usa
14 veces en 11 archivos de la web y los bloques del CMS.
Ver los archivos
- apps/web/src/pages/dev/homes.astro ×3
- apps/web/src/sections/listings/ListingsGrid.astro ×2
- apps/web/src/lib/dev-home-card-fixtures.ts ×1
- apps/web/src/sections/blog/PostBody.astro ×1
- apps/web/src/sections/destinations/DestinationHomes.astro ×1
- apps/web/src/sections/homes/home-card.ts ×1
- apps/web/src/sections/listing/SimilarHomes.astro ×1
- apps/web/src/sections/listings/ListingsFeatured.astro ×1
- apps/web/src/sections/press/PressRow.astro ×1
- packages/cms-blocks/src/renderers/HomeShowcase/Grid.astro ×1
- packages/cms-blocks/src/renderers/lib/landing-card.ts ×1