Veil UI
Components

Spacer

Adds flexible or fixed space between flex children.

Installation

$ npx veil-ui@latest add spacer

Usage

import { Spacer } from "@/components/ui/spacer";

<div className="flex items-center">
  <span>Left</span>
  <Spacer />
  <span>Right</span>
</div>;

Examples

Flexible

LeftRight

Fixed size

Toolbar

API reference

PropTypeDefaultDescription
size"xs" | "sm" | "md" | "lg" | "xl"—Fixed size: 4, 8, 16, 24 or 32px. Omit to fill the remaining space.
...propsReact.ComponentProps<"div">—All native div attributes.

Accessibility

  • Renders an aria-hidden element, so it is invisible to assistive technology.
  • It must live inside a flex container; otherwise use margins instead.

Vue and plain HTML

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

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

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

const sizes = {
  xs: "size-1",
  sm: "size-2",
  md: "size-4",
  lg: "size-6",
  xl: "size-8",
} as const;

const props = defineProps<{
  size?: keyof typeof sizes;
  class?: string;
}>();

const classes = computed(() =>
  cn(props.size ? cn("shrink-0", sizes[props.size]) : "flex-1", props.class),
);
</script>

<template>
  <div aria-hidden="true" data-slot="spacer" :class="classes" />
</template>

On this page