Overview

Pass an options object with box-model shorthands: p, m, w, maxw, bgcolor, br, display, grow, and more.

Numbers use the 8px scale; strings pass through as CSS.

Constrained card via box()

Centered max-width panel with an inline badge — no extra nodes.

import { html, renderApp } from 'mates';
import { box } from 'mates-ui';

const App = () => {
return () => html`
<div class="card card-body m-w-full">
<main ${box({ maxw: '420px', mx: 'auto', p: 2, bgcolor: 'var(--m-surface)', br: 'var(--m-r)' })}>
<h3>Constrained card</h3>
<p class="muted">
box() applies the same shorthand props as &lt;x-box&gt; without an extra node.
</p>
<span ${box({
display: 'inline-flex',
mt: 1,
px: '0.75rem',
py: '0.2rem',
br: '9999px',
bgcolor: 'var(--m-bg)',
})} class="hint">Badge</span>
</main>
</div>
`;
};

renderApp(App, document.getElementById('app'));