Saltar al contenido
DS

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.

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.

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.

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.

Props

<Columns>

Props de 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>

Props de 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
esc