Components
Heading
Semantic h1–h6 headings with matching visual sizes.
Installation
$ npx veil-ui@latest add headingUsage
import { Heading } from "@/components/ui/heading";
<Heading level={1}>Own your interface.</Heading>;Examples
Basic
Own your interface.
Levels
Level one
Level three
Level six
Visual override
A small h2 with a quiet tone
A large h6 for visual emphasis
Keep the semantic level correct and use size only to change the visual scale.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| level | 1 | 2 | 3 | 4 | 5 | 6 | 2 | Heading level and default visual size. |
| size | 1 | 2 | 3 | 4 | 5 | 6 | — | Visual size override that leaves the element unchanged. |
| weight | "normal" | "medium" | "semibold" | "bold" | "semibold" | Font weight preset. |
| tone | "default" | "muted" | "default" | Foreground color tone. |
Accessibility
- The element matches
level, so the document outline stays correct even when the visual size is overridden. - Keep one
h1per page and avoid skipping levels. - Text is balanced with
text-balanceto reduce awkward line breaks in large headings.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add heading --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { cn } from "@/lib/utils";
import type { HeadingProps } from "./types";
const sizes = {
1: "text-4xl",
2: "text-3xl",
3: "text-2xl",
4: "text-xl",
5: "text-lg",
6: "text-base",
} as const;
const weights = {
normal: "font-normal",
medium: "font-medium",
semibold: "font-semibold",
bold: "font-bold",
} as const;
const props = withDefaults(defineProps<HeadingProps>(), {
level: 2,
weight: "semibold",
tone: "default",
});
</script>
<template>
<component
:is="'h' + props.level"
data-slot="heading"
:data-level="props.level"
:class="
cn(
'text-balance tracking-tight',
sizes[props.size ?? props.level],
weights[props.weight],
props.tone === 'muted' && 'text-muted-foreground',
props.class,
)
"
>
<slot />
</component>
</template>