Components
Key Value List
A definition list for metadata with optional copy buttons.
Installation
$ npx veil-ui@latest add key-value-listUsage
import { KeyValueList } from "@/components/ui/key-value-list";
<KeyValueList
items={[
{ label: "Workspace", value: "Northwind" },
{ label: "API key", value: "sk_live_••••42", copyValue: "sk_live_key" },
]}
/>;Examples
Basic
- Workspace
- Northwind
- Plan
- Team
- Region
- eu-central-1
- API key
- sk_live_••••42
Two columns
- Owner
- Ada Lovelace
- Created
- Mar 2, 2026
- Status
- Active
- Seats
- 12 of 20
API reference
The package exports key-value-list along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.
Accessibility
- Content uses semantic HTML — lists are lists, tables are tables and metadata uses a definition list.
- Interactive elements are real buttons or links with visible focus states.
- Images require meaningful
alttext; icons used decoratively arearia-hidden.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add key-value-list --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { Check, Copy } from "lucide-vue-next";
import { computed, ref } from "vue";
import { cn } from "@/lib/utils";
import type { KeyValueItem } from "./types";
const props = withDefaults(
defineProps<{
items: KeyValueItem[];
columns?: 1 | 2;
class?: string;
}>(),
{ columns: 1 },
);
const copied = ref<string | null>(null);
const entries = computed(() =>
props.items.map((item, index) => ({
...item,
key: typeof item.label === "string" ? item.label : `item-${index}`,
})),
);
async function copy(key: string, value?: string) {
if (!value) return;
try {
await navigator.clipboard.writeText(value);
copied.value = key;
window.setTimeout(() => {
copied.value = null;
}, 1500);
} catch {
copied.value = null;
}
}
</script>
<template>
<dl
data-slot="key-value-list"
:class="
cn(
'grid gap-x-6 gap-y-3 text-sm',
columns === 2 && 'sm:grid-cols-2',
props.class,
)
"
>
<div v-for="item in entries" :key="item.key" class="flex flex-col gap-0.5">
<dt class="text-muted-foreground">{{ item.label }}</dt>
<dd class="flex items-center gap-2 font-medium">
<span>{{ item.value }}</span>
<button
v-if="item.copyValue"
type="button"
:aria-label="`Copy ${item.key}`"
class="inline-flex size-6 items-center justify-center rounded text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
@click="copy(item.key, item.copyValue)"
>
<Check v-if="copied === item.key" class="size-3.5" aria-hidden="true" />
<Copy v-else class="size-3.5" aria-hidden="true" />
</button>
</dd>
</div>
</dl>
</template>