Vitral 0.2
Layout

Grid

A grid with star sizing: rows and columns sized to content, as shares of what is left, or in pixels, with children placed by row and column.

Import

main.ts
import { Grid } from '@vitral/vue';

Definitions

rows="Auto,*,2*,48" columns="160,*,Auto", with showGridLines outlining each cell.

row 0 · Auto — spans 3 columns
rows 1–2 · column 0 (160px)
row 1 (*) · column 1 (*)
row 2 (2*) · column 1
column 2 · Auto
row 3 · 48px
<script setup lang="ts">import { Grid, GridItem } from '@vitral/vue';import { ref } from 'vue'; const lines = ref(true);</script> <template>    <label class="toggle"><input v-model="lines" type="checkbox" /> showGridLines</label>    <Grid class="frame" rows="Auto,*,2*,48" columns="160,*,Auto" :row-spacing="6" :column-spacing="6" :show-grid-lines="lines">        <GridItem class="box c1" :column-span="3">row 0 · Auto — spans 3 columns</GridItem>        <GridItem class="box c2" :row="1" :row-span="2">rows 1–2 · column 0 (160px)</GridItem>        <GridItem class="box c3" :row="1" :column="1">row 1 (*) · column 1 (*)</GridItem>        <GridItem class="box c4" :row="2" :column="1">row 2 (2*) · column 1</GridItem>        <GridItem class="box c5" :row="1" :column="2" :row-span="2">column 2 · Auto</GridItem>        <GridItem class="box c1" :row="3" :column-span="3">row 3 · 48px</GridItem>    </Grid></template> <style scoped>.toggle {    display: inline-flex;    align-items: center;    gap: 0.375rem;    width: 100%;    font-size: 0.8125rem;} .frame {    width: 100%;    height: 20rem;    padding: 0.5rem;    border: 1px dashed color-mix(in srgb, var(--vt-text-color) 30%, transparent);    border-radius: var(--vt-border-radius-md);} .box {    --c: var(--vt-chart-1);    display: flex;    align-items: center;    justify-content: center;    padding: 0.375rem 0.625rem;    font-size: 0.8125rem;    text-align: center;    color: var(--vt-text-color);    background: color-mix(in srgb, var(--c) 18%, transparent);    border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);    border-radius: var(--vt-border-radius-sm);} .c1 {    --c: var(--vt-chart-1);}.c2 {    --c: var(--vt-chart-2);}.c3 {    --c: var(--vt-chart-3);}.c4 {    --c: var(--vt-chart-4);}.c5 {    --c: var(--vt-chart-5);}</style>

A form

columns="Auto,*": labels take what they need, fields take the rest. Row and column spacing are set separately.

<script setup lang="ts">import { Grid, GridItem, InputText } from '@vitral/vue';</script> <template>    <Grid class="form" rows="Auto,Auto,Auto" columns="Auto,*" :row-spacing="10" :column-spacing="16">        <GridItem as="label" for="grid-name" class="label">Name</GridItem>        <GridItem :column="1"><InputText id="grid-name" fluid placeholder="Ada Lovelace" /></GridItem>        <GridItem as="label" for="grid-email" :row="1" class="label">Email address</GridItem>        <GridItem :row="1" :column="1"><InputText id="grid-email" type="email" fluid placeholder="ada@example.com" /></GridItem>        <GridItem as="label" for="grid-city" :row="2" class="label">City</GridItem>        <GridItem :row="2" :column="1"><InputText id="grid-city" fluid placeholder="London" /></GridItem>    </Grid></template> <style scoped>.form {    width: 100%;    max-width: 32rem;    align-items: center;} .label {    font-size: 0.8125rem;    font-weight: 500;}</style>

API

Read from packages/vue/src/components/Grid/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
rowsstring | (string | number)[]The row tracks. Left out, the grid has one row that fills it.
columnsstring | (string | number)[]The column tracks. Left out, the grid has one column that fills it.
rowSpacingnumber | stringSpace between rows. Defaults to the `grid.rowSpacing` token.
columnSpacingnumber | stringSpace between columns. Defaults to the `grid.columnSpacing` token.
showGridLinesbooleanOutlines the grid and every cell: the debugging aid.
asstring | Component—

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Slots

NameSlot propsDescription
default——