Componentes · Maquetación
Columnas <Columns>
La rejilla de 12 · 8 · 4 columnas de Foundations.
import Columns from '@vivla-cms/ds/primitives/Columns.astro'Ejemplos
La rejilla 12 · 8 · 4
12 columnas en escritorio, 8 en tableta, 4 en móvil, con 20 px de medianil (Foundations Grid 142:2). Usa Móvil · Tableta · Escritorio abajo para ver cómo cambia el número de columnas.
---
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'
---
<Container class="py-8">
<Columns gapY="none">
{
Array.from({ length: 12 }, (_, i) => (
<Col mobile={1} tablet={1} desktop={1} class:list={['h-24 bg-accent/20 text-center text-small leading-[6rem] text-on-surface', i >= 4 && 'max-md:hidden', i >= 8 && 'max-lg:hidden']}>
{i + 1}
</Col>
))
}
</Columns>
</Container> Cuántas columnas ocupa cada pieza
Col recibe un span por tamaño: mobile (de 4), tablet (de 8) y desktop (de 12). Por defecto ocupa todo el ancho. Aquí, el patrón de texto + foto: apilados en móvil, mitad y mitad en tableta, 5 + 7 en escritorio.
---
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 Heading from '@vivla-cms/ds/primitives/Heading.astro'
import Media from '@vivla-cms/ds/primitives/Media.astro'
import Text from '@vivla-cms/ds/primitives/Text.astro'
---
<Container class="py-10">
<Columns gapY="lg">
<Col mobile={4} tablet={4} desktop={5} class="flex flex-col gap-4">
<code class="font-mono text-small text-on-surface-subtle">mobile 4 · tablet 4 · desktop 5</code>
<Heading level={3}>Llegar y que todo esté listo</Heading>
<Text tone="muted">Nevera llena, camas hechas y alguien a quien llamar si hace falta.</Text>
</Col>
<Col mobile={4} tablet={4} desktop={7} class="flex flex-col gap-2">
<code class="font-mono text-small text-on-surface-subtle">mobile 4 · tablet 4 · desktop 7</code>
<Media src="/assets/home/feat-booking-1024.avif" alt="Salón de una casa VIVLA" aspect="4/3" />
</Col>
</Columns>
</Container> Cambiar el número de columnas
cols cambia el recuento sin escribir CSS: una rejilla de tarjetas a 1 · 2 · 3 columnas (móvil · tableta · escritorio). Cada Col ocupa 1.
---
import Card from '@vivla-cms/ds/primitives/Card.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'
const places = ['Ibiza', 'Menorca', 'Mallorca', 'Baqueira', 'Sotogrande', 'Costa Brava']
---
<Container class="py-10">
<Columns cols={{ mobile: 1, tablet: 2, desktop: 3 }}>
{
places.map((place) => (
<Col mobile={1} tablet={1} desktop={1}>
<Card tone="alt" padding="md">
<Text weight="medium">{place}</Text>
</Card>
</Col>
))
}
</Columns>
</Container> Medianiles
gapX y gapY toman la escala: grid (20 px, el medianil de Foundations, por defecto en horizontal), stack (64 px, entre cabecera, contenido y CTA) y, solo en vertical, section (108 px) para filas que se leen como bandas. También none, sm, md, lg, xl, 2xl.
---
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'
const gaps = ['none', 'grid', 'xl', 'stack'] as const
---
<Container class="flex flex-col gap-8 py-10">
{
gaps.map((gap) => (
<div class="flex flex-col gap-2">
<code class="font-mono text-small text-on-surface-subtle">gapX="{gap}" gapY="{gap}"</code>
<Columns gapX={gap} gapY={gap} cols={{ mobile: 2, tablet: 4, desktop: 6 }}>
{Array.from({ length: 6 }, () => (
<Col mobile={1} tablet={1} desktop={1} class="h-10 bg-accent/20" />
))}
</Columns>
</div>
))
}
</Container> Props
<Columns>
| Prop | Valores | Por defecto | Para qué |
|---|---|---|---|
| gapX | nonesmmdlgxl2xlgridstack | 'grid' | — |
| gapY | Gap | 'section' | 'md' | Row gap: the gap scale, or the section spacing token. |
| cols | ColsOverride | — | — |
| as | keyof HTMLElementTagNameMap | — | — |
| [string] | unknown | — | Se pasan tal cual al elemento. |
Slots: contenido
<Col>
| Prop | Valores | Por defecto | Para qué |
|---|---|---|---|
| mobile | 1234 | 4 | — |
| tablet | Span | 8 | — |
| desktop | Span | 12 | — |
| as | keyof HTMLElementTagNameMap | — | — |
| [string] | unknown | — | Se pasan tal cual al elemento. |
Slots: contenido
Notas del código
El comentario de cabecera de Columns.astro, tal cual (en inglés, como el código): si cambia el código, cambia esto.
12-8-4 responsive column grid. Use INSIDE a Container / Section — this primitive owns the column rhythm, not the page width or edge gutter. Children should be <Col> (or any element with col-span-N classes).
<Container>
<Columns gapY="lg">
<Col desktop={5} tablet={8} mobile={4}>...</Col>
<Col desktop={7} tablet={8} mobile={4}>...</Col>
</Columns>
</Container> Default cadence: 4 cols mobile / 8 cols tablet / 12 cols desktop. Pass cols to override the count at any breakpoint without writing CSS. Ported from cms-blocks/_ui with the same prop API; the grid itself is the ds-grid utility in base.css.
Foundations Layout · Retícula (768:48): 12 columns of 101, 20 px gutter («Medianil»), 40 px margin on a 1512 canvas → 1432 of content; 4 columns of 87, 20 px gutter, 16 px margin at 440 → 408. The default column gap is that gutter (grid = --spacing-grid, 20 px). At the 1512 canvas a desktop column measures 101 px and n columns measure n × 101 + (n − 1) × 20 (Layout 768:97: 5 columns = 585 = --container-prose, the reading measure; 6 = 706; 12 = 1432). At every other width the columns stretch and the margins hold («Stretch») — above 1512 too since 05/11, when the container lost its cap (a column is 120 px at 1728, 188 at 2560). Tablet (8 columns) is ours: Figma draws none.
The scale also takes the rhythm tokens: stack = --spacing-stack (64 px, between header, content and CTA) and, for gapY only, section = --spacing-section (80 px on phones, 104 from lg — Section's two fixed steps) for grids whose rows read as separate bands.
<Columns gapY="stack">…</Columns> <Col>
Column child for <Columns>. Spans are resolved against the parent's current column count at each breakpoint (4 mobile / 8 tablet / 12 desktop by default), so:
<Col mobile={4} tablet={4} desktop={6} /> reads as: full-width on mobile, half on tablet (4/8), half on desktop (6/12).
Defaults to a full-width slot at every breakpoint, which is the right starting point for vertically stacked content.
Dónde se usa
75 veces en 53 archivos de la web y los bloques del CMS.
Ver los archivos
- apps/web/src/pages/dev/kit/media.astro ×5
- apps/web/src/pages/dev/kit.astro ×4
- apps/web/src/pages/dev/kit/lead.astro ×4
- apps/web/src/pages/dev/kit/type.astro ×4
- apps/web/src/pages/dev/kit/video-parts.astro ×3
- packages/cms-blocks/src/renderers/Media.astro ×3
- apps/web/src/sections/press/PressRow.astro ×2
- packages/cms-blocks/src/renderers/EditorialFeatures/stacked.astro ×2
- packages/cms-blocks/src/renderers/EditorialText.astro ×2
- packages/cms-blocks/src/renderers/HomeShowcase/Slide.astro ×2
- packages/cms-blocks/src/renderers/Statement/media.astro ×2
- apps/web/src/layouts/chrome/ContactFormBand.astro ×1
- apps/web/src/pages/dev/homes.astro ×1
- apps/web/src/sections/blog/Newsletter.astro ×1
- apps/web/src/sections/blog/PostGrid.astro ×1
- apps/web/src/sections/blog/PostHeader.astro ×1
- apps/web/src/sections/destinations/DestinationEconomics.astro ×1
- apps/web/src/sections/destinations/DestinationHomes.astro ×1
- apps/web/src/sections/listing/ListingDesign.astro ×1
- apps/web/src/sections/listing/ListingEconomics.astro ×1
- apps/web/src/sections/listing/ListingFinishes.astro ×1
- apps/web/src/sections/listing/ListingHero.astro ×1
- apps/web/src/sections/listing/SimilarHomes.astro ×1
- apps/web/src/sections/listings/ListingsGrid.astro ×1
- apps/web/src/sections/press/PressHero.astro ×1
- packages/cms-blocks/src/renderers/Accordion/split.astro ×1
- packages/cms-blocks/src/renderers/Accordion/stacked.astro ×1
- packages/cms-blocks/src/renderers/CardGrid/grid.astro ×1
- packages/cms-blocks/src/renderers/CardGrid/offset.astro ×1
- packages/cms-blocks/src/renderers/CardGrid/overlay.astro ×1
- packages/cms-blocks/src/renderers/Chapter/figure.astro ×1
- packages/cms-blocks/src/renderers/Chapter/inset.astro ×1
- packages/cms-blocks/src/renderers/Chapter/split.astro ×1
- packages/cms-blocks/src/renderers/ContactPanel.astro ×1
- packages/cms-blocks/src/renderers/EditorialFeatures/diptych.astro ×1
- packages/cms-blocks/src/renderers/EditorialFeatures/inset.astro ×1
- packages/cms-blocks/src/renderers/EditorialFeatures/parts/HeaderImages.astro ×1
- packages/cms-blocks/src/renderers/EditorialFeatures/split.astro ×1
- packages/cms-blocks/src/renderers/EditorialFeatures/wide.astro ×1
- packages/cms-blocks/src/renderers/FeatureList/list.astro ×1
- packages/cms-blocks/src/renderers/FeatureList/panel.astro ×1
- packages/cms-blocks/src/renderers/Gallery.astro ×1
- packages/cms-blocks/src/renderers/Hero/image.astro ×1
- packages/cms-blocks/src/renderers/Hero/media.astro ×1
- packages/cms-blocks/src/renderers/Hero/text.astro ×1
- packages/cms-blocks/src/renderers/Hero/textOverMedia.astro ×1
- packages/cms-blocks/src/renderers/HomeShowcase/Grid.astro ×1
- packages/cms-blocks/src/renderers/NumberedList/columns.astro ×1
- packages/cms-blocks/src/renderers/NumberedList/rows.astro ×1
- packages/cms-blocks/src/renderers/Statement/columns.astro ×1
- packages/cms-blocks/src/renderers/Statement/cta.astro ×1
- packages/cms-blocks/src/renderers/Statement/portrait.astro ×1
- packages/cms-blocks/src/renderers/Statement/text.astro ×1