DlCodeInline

Display inline code that stays on one line

The DlCodeInline inline component renders a semantic <code> snippet with the same look as Markdown backticks, but keeps the text on a single line. Use it when backtick code would wrap in prose, or when you need inline code inside tables and other tight layouts.

The Why

DocLayer styles regular inline code with wrap-anywhere inside paragraphs and lists, so long identifiers can break across lines. Tables already force whitespace-nowrap on native code elements, but that behavior is not consistent everywhere. DlCodeInline applies a small, overridable UI layer so authors can opt into nowrap inline code without custom HTML or inline style attributes.

Features

  • 📎 semantic <code> output (inherits global inline code theme)
  • ↔️ keeps snippets on one line (whitespace-nowrap)
  • đź§© works with default slot or code prop
  • 🎛️ stylable via iui / #ui on base
  • ⚠️ extensive error reporter when content is missing

Usage

Use :dl-code-inline as an inline component with the snippet in the default slot or the code prop.

:dl-code-inline[content.config.ts]
:dl-code-inline{code="content.config.ts"}

Result: content.config.ts

Within tables

Prefer the code prop when the snippet contains characters that confuse MDC or table syntax (for example | in TypeScript unions).

| :dl-code-inline{code="Record<string, string>"} | Description |

See also the writing guide for more table recipes.

Compared with backticks and DlFormat

  • Markdown backticks are best for short inline mentions in running text.
  • DlFormat parses lightweight Markdown (bold, italic, nested backticks) into HTML.
  • DlCodeInline is for a literal code string that must stay on one line and should not be reformatted.

Props

Here are the properties you can use with the DlCodeInline component. Each property should be set on an individual component instance; they do not affect the global configuration. More about defining properties in MDC components you can read here.

nametypedefaultdescription
lazybooleanfalse

Whether to lazy load the component.

codestringundefined

Inline code snippet. Use when the default slot is impractical (tables, pipes, or other MDC edge cases).

iuiRecord<string, string>undefined

Special property dedicated to inline components, can be used to add TW classes for certain component markup elements.

Slots

namedescription
default

Code snippet text. Ignored when the code prop is provided.

Styling

Styling from Markdown

Every DocLayer component can be styled directly within your Markdown file using dedicated slot/property configuration. This allows you to customize the appearance of the component's markup elements without modifying global styles. More about components styling you can read here.

Below you'll find the default set of Tailwind classes for the component's dedicated markup elements.

DlCodeInline relies on global code styles for colors, padding, and borders. The component UI only adds layout overrides:

<script lang="ts">const ui = defineDoclayerComponentUi({  base: ['max-w-none', 'whitespace-nowrap!'],});</script>

Override defaults per instance with :iui, or globally via dl.components when supported.

Accessibility

DlCodeInline renders a native <code> element with an accessible name. Keep snippets short and meaningful; use surrounding prose to explain longer references.