Code

An identifier written inside prose: a prop, a class, a variable. Muted where it sits among other identifiers, filled where it has to stand out of a sentence.

API

Props

proptypedefault
as?ElementType"code"the element or component to render
filled?booleanfalseadds the surface, the padding and the radius
className?stringmerged over the defaults, so it wins
…restprops of astyped against the chosen element

Examples

In a sentence

filled gives the identifier a surface, so it survives being surrounded by words. Use it in running text, where the eye has to find the term before reading it.

tsx
<p>
  Pass <Code filled>className</Code> and it is merged over the defaults.
</p>

<p>
  The same sentence without <Code>filled</Code>, where the term blends into the line.
</p>

Pass className and it is merged over the defaults.

The same sentence without filled, where the term blends into the line.

In a column of identifiers

Bare is the default because the common case is a table, where every cell is already an identifier and a surface on each one would be noise. What separates them there is the column, not a fill.

tsx
<Code>ElementType</Code>
<Code>boolean</Code>
<Code>props of as</Code>
ElementTypebooleanprops of as

Details

Muted on purpose

The resting colour is medium, the same secondary text the kit uses everywhere else. An identifier is rarely the sentence — it is the thing the sentence is about — and rendering it at full contrast makes a paragraph read as a list of terms with prose between them.

When the identifier is the subject rather than the reference — the name of the prop a row documents — raise it with a className. Deciding that per column is the point: the component sets the resting state, the call site says which one matters.

The typeface is declared, not inherited

The monospace comes from the component, not from the browser. A code element is styled by the reset with the default mono family, which works until the element is rendered as something else: with as pointing at a span the reset no longer applies, and an identifier would quietly become prose.