Veil UI
Components

Grid

A responsive grid with sensible column breakpoints.

Installation

$ npx veil-ui@latest add grid

Usage

import { Grid } from "@/components/ui/grid";

<Grid cols={3} gap="md">
  <Item />
  <Item />
  <Item />
</Grid>;

Examples

Three columns

Tokens
Colors, radius and typography.
Components
Accessible building blocks.
Blocks
Composed page sections.

Two columns

Preview
Live component examples.
Code
The exact source that ships.

Dashboard tiles

Requests

99.9%

Errors

99.9%

Latency

99.9%

Uptime

99.9%

API reference

PropTypeDefaultDescription
cols1 | 2 | 3 | 4 | 6 | 123Target column count at the largest breakpoint. Smaller viewports collapse to 1–4 columns.
gap"none" | "xs" | "sm" | "md" | "lg" | "xl""md"Space between cells: 0, 4, 8, 16, 24 or 32px.
...propsReact.ComponentProps<"div">—All native div attributes.

Accessibility

  • Presentational layout primitive with no ARIA roles.
  • Responsive classes are static per cols value, so Tailwind can detect them.
  • Source order follows DOM order at every breakpoint; use it for reading order, not just visual placement.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add grid --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { computed } from "vue";

import { cn } from "@/lib/utils";

const columns = {
  1: "grid-cols-1",
  2: "grid-cols-1 sm:grid-cols-2",
  3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
  4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
  6: "grid-cols-2 md:grid-cols-3 lg:grid-cols-6",
  12: "grid-cols-4 md:grid-cols-6 lg:grid-cols-12",
} as const;

const gaps = {
  none: "gap-0",
  xs: "gap-1",
  sm: "gap-2",
  md: "gap-4",
  lg: "gap-6",
  xl: "gap-8",
} as const;

const props = withDefaults(
  defineProps<{
    cols?: keyof typeof columns;
    gap?: keyof typeof gaps;
    class?: string;
  }>(),
  { cols: 3, gap: "md" },
);

const classes = computed(() =>
  cn("grid", columns[props.cols], gaps[props.gap], props.class),
);
</script>

<template>
  <div data-slot="grid" :data-cols="cols" :class="classes">
    <slot />
  </div>
</template>

On this page