Code
Code is set in Iosevka Charon Mono. Inline code is a small chip; blocks are dark boxes that wrap long lines by default, with an optional copy button.
Inline
Install with npm install momo-ui, then press Ctrl + K to search.
<p>Install with <code>npm install momo-ui</code>, then press <kbd>Ctrl</kbd> + <kbd>K</kbd> to search.</p>Any <code> outside a block becomes a chip; <kbd> looks like a key.
Block with a copy button
Wrap a <pre> in .code. A .code-copy button with data-momo-copy copies the block; it shows "Copied" for a moment and tells screen readers. Put it in a .code-head with a file name, or alone (it floats top-right).
<link rel="stylesheet" href="momo.css">
<script src="momo.js" defer></script>
npm install momo-ui
<div class="code">
<div class="code-head"><span>index.html</span><button class="code-copy" type="button" data-momo-copy><i class="mi mi-copy" aria-hidden="true"></i> Copy</button></div>
<pre><code><link rel="stylesheet" href="momo.css">
<script src="momo.js" defer></script></code></pre>
</div>
<div class="code">
<button class="code-copy" type="button" data-momo-copy><i class="mi mi-copy" aria-hidden="true"></i> Copy</button>
<pre><code>npm install momo-ui</code></pre>
</div>Wrapping
Long lines wrap by default, so nothing ever scrolls sideways on a phone. Add .code-nowrap when a line must stay whole (it scrolls inside its box instead).
const message = 'This is a very long line of code that keeps going so you can see it wrap onto the next line instead of making the page scroll sideways';
const message = 'This line does not wrap: it scrolls inside the box, and the page itself never scrolls sideways';
<div class="code">
<pre><code>const message = 'This is a very long line of code that keeps going so you can see it wrap onto the next line instead of making the page scroll sideways';</code></pre>
</div>
<div class="code code-nowrap">
<pre><code>const message = 'This line does not wrap: it scrolls inside the box, and the page itself never scrolls sideways';</code></pre>
</div>Light
.code-light uses the paper color, for docs inside light cards.
:root {
--momo-brand: var(--momo-violet);
}
<div class="code code-light">
<div class="code-head"><span>styles.css</span><button class="code-copy" type="button" data-momo-copy><i class="mi mi-copy" aria-hidden="true"></i> Copy</button></div>
<pre><code>:root {
--momo-brand: var(--momo-violet);
}</code></pre>
</div>Copy anything
data-momo-copy works on any button: data-momo-copy="#id" copies that element (or a field's value), data-momo-copy-text="…" copies fixed text. Listen for momo:copy to show a toast.
<div class="input-group">
<input class="form-control" id="share-link" value="https://momo.test/invite/8f2k" readonly aria-label="Invite link">
<button class="btn" type="button" data-momo-copy="#share-link"><i class="mi mi-copy"></i> Copy link</button>
</div>