Code
Inline code for a function name, prop, file path or CLI flag inside prose.
Status: beta. Group: display. Markdown version: /design-system/components/code.md
When to use
Code marks a short literal inside running text. Match its size to the text around it: sm beside Body xxs and xs, md beside s and m, lg beside l.
When not to use
- Do not use for a multi-line block or a command meant to be copied; use CodeBlock or Snippet.
- Do not use for keyboard keys; that is Kbd.
Look-alikes
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
size | "sm" | "md" | "lg" | md | Match the surrounding text: sm beside Body xxs/xs, md beside s/m, lg beside l. | No |
Variants
- Available sizes:
sm,md,lg,inherit(defaultmd).
Invalid combinations
The contract records no invalid combinations.
Keyboard
The contract records no keyboard interaction.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | ARIA: None: static text with code semantics. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-10-25. |
| SHOULD | Use for identifiers, props, file paths, environment variables and CLI flags inside a sentence. | Not stated in the contract. |
| SHOULD | Keep it to a few words; a line of code belongs in Snippet or CodeBlock. | Not stated in the contract. |
| SHOULD NOT | Do not add a copy button or make it a link target; it is static text. | Not stated in the contract. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { Code } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/contentexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary. - Also available as the custom element
<dt-code>; see the custom elements manifest.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.