Components
Code
Inline code with a subtle background and monospace type.
Installation
$ npx veil-ui@latest add codeUsage
import { Code } from "@/components/ui/code";
<p>
Run <Code>npx veil-ui add button</Code> to copy the component.
</p>;Examples
Basic
pnpm dlx veil-ui initIn a sentence
Run npx veil-ui@latest add button to copy the button into your project.
For multi-line samples use Code Block, which adds a copy button, filename label and line numbers.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | ComponentProps<'code'> | — | All native code attributes. |
Accessibility
- Uses the native
<code>element, so assistive technology can identify it as code. - Text inherits the surrounding font size proportionally and keeps a contrast ratio close to body copy.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add code --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { cn } from "@/lib/utils";
const props = defineProps<{ class?: string }>();
</script>
<template>
<code
data-slot="code"
:class="
cn(
'rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground',
props.class,
)
"
>
<slot />
</code>
</template>