Veil UI
Components

Center

Centers its children horizontally and vertically.

Installation

$ npx veil-ui@latest add center

Usage

import { Center } from "@/components/ui/center";

<Center className="h-64">
  <Spinner />
</Center>;

Examples

Basic

Centered content

Full height

Sign in to continue

Empty state

Nothing here yet

Add flex-col when the content should stack, as in the empty state.

API reference

PropTypeDefaultDescription
...propsReact.ComponentProps<"div">—All native div attributes. Pass a height or min-height to give the centering a box.

Accessibility

  • Presentational wrapper only; it adds no roles.
  • Centering is visual. Keep the DOM order logical, and give the centered content a real heading or label when it carries meaning.

Vue and plain HTML

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

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

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

const props = defineProps<{ class?: string }>();

const classes = computed(() => cn("flex items-center justify-center", props.class));
</script>

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

On this page