Rost

← All components

component

Code

Code in a sentence, or a block of it on its own plate.

In code Contract: review Guidance: proposed Contract on GitHub Figma 705:104 As markdown
non-interactive/foreground/positive/base
False
<Link href="/docs/">Docs</Link>
<Link tone="quiet">GitHub</Link>
True

Install

npx github:Runceanu/rost add code

It lands in src/rost/code/, with what it needs and its contract. Install has the rest.

When to use

  • A name in a sentence

    A prop, a token path or a file name inside running text: tone=quiet, contracts/link.contract.yaml.

  • What to write

    A few lines someone will copy. Coloured by a highlighter, or plain.

When not to use

  • Emphasis

    Making a word stand out. Code means the word is exactly what you type.

  • Very long files

    A whole file on a page. Show the part that matters, and link to the rest.

Behaviour

In a sentence it's the mono family at a slightly smaller size, with no plate, so a line full of token paths stays calm. A block gets the secondary plate, 16px inside and 12px corners, and scrolls sideways rather than wrapping. The colours inside a block come from the highlighter, not from Rost. On the Rost site that's Shiki's vesper in dark and GitHub's high-contrast theme in light, with the comment greys made solid, so every word is 4.5:1 on the plate. Syntax colours as tokens would be the next step, and I haven't needed them in an app yet.

Accessibility

  • Element

    <code>, and <pre> around it for a block, so a screen reader keeps the spacing.

  • Keyboard

    A block that scrolls gets tabindex="0", so it can be scrolled without a mouse.

Content

Exactly what someone types. No ellipsis inside a line they'd copy.

Props

PropTypeValuesDefault
block boolean false
html string
children slot

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • font-family 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace on purpose: Rost has no mono family token yet. Where JetBrains Mono isn't loaded, the system mono stands in.
  • font-size 0.88em on purpose: In a sentence it follows the text around it. Mono looks bigger than General Sans at the same size, so a little smaller.

overflow-wrapanywhere · line-height1

text

fontinherit

Only in some variants

These don't change: they're just set in some variants and not others.

Every variant

  • root.background #171717 non-interactive/background/secondary
  • root.border-radius 12px spacing/radius/medium
  • root.color #ededed non-interactive/foreground/primary
  • root.display block layout
  • root.font-size 12px typography/label/font-size
  • root.line-height 20px typography/line-height/20
  • root.overflow-wrap normal Figma frame size
  • root.overflow-x auto Figma frame size
  • root.padding-bottom 16px spacing/gap/medium
  • root.padding-left 16px spacing/gap/medium
  • root.padding-right 16px spacing/gap/medium
  • root.padding-top 16px spacing/gap/medium
  • root.white-space pre layout