Veil UI
Components

Cluster

Wraps a set of items with even gaps and sensible alignment.

Installation

$ npx veil-ui@latest add cluster

Usage

import { Cluster } from "@/components/ui/cluster";

<Cluster gap="sm">
  <Badge>React</Badge>
  <Badge>Tailwind</Badge>
  <Badge>Radix UI</Badge>
</Cluster>;

Examples

Basic

ReactTailwindRadix UITypeScript

Space between

Filters

Tag list

designdocsregistry

Cluster is a flex row that wraps. Use it for tag lists, toolbars and any row of items that should reflow on narrow screens.

API reference

PropTypeDefaultDescription
gap"none" | "xs" | "sm" | "md" | "lg" | "xl""sm"Space between items: 0, 4, 8, 16, 24 or 32px.
align"start" | "center" | "end" | "baseline""center"Cross-axis alignment.
justify"start" | "center" | "end" | "between" | "around""start"Main-axis distribution.
...propsReact.ComponentProps<"div">—All native div attributes.

Accessibility

  • Presentational flex wrapper; it adds no ARIA roles or landmarks.
  • gap, align and justify map to static classes, so they work with Tailwind's compiler and never rely on runtime string interpolation.

Vue and plain HTML

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

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

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

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

const alignments = {
  start: "items-start",
  center: "items-center",
  end: "items-end",
  baseline: "items-baseline",
} as const;

const justifications = {
  start: "justify-start",
  center: "justify-center",
  end: "justify-end",
  between: "justify-between",
  around: "justify-around",
} as const;

const props = withDefaults(
  defineProps<{
    gap?: keyof typeof gaps;
    align?: keyof typeof alignments;
    justify?: keyof typeof justifications;
    class?: string;
  }>(),
  { gap: "sm", align: "center", justify: "start" },
);

const classes = computed(() =>
  cn(
    "flex flex-wrap",
    gaps[props.gap],
    alignments[props.align],
    justifications[props.justify],
    props.class,
  ),
);
</script>

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

On this page