Layout
The structure of a page, the areas that group content, and the classes that place them.
Page structure
<body> is a column that fills the height of the window. <header> is fixed to the top over a blurred background; its first <div> takes the remaining width, so the second one is at the end. <main> stacks its children with a gap of 16px, and leaves room at the top for the header.
<body>
<header>
<div><a href="/">Home</a></div>
<div><a href="/about/">About</a></div>
</header>
<main>…</main>
</body>Sidebar
A <nav class="sidebar"> before <main> is fixed to the start of the page, and <main> makes room for it. Up to 768px wide, it is hidden and opens as a popover over the page from a sidebar-toggle button, which is shown only there. The popover is native HTML, so it opens without JavaScript. This site uses it on these pages.
<header>
<div>
<button class="sidebar-toggle" type="button" popovertarget="sidebar" aria-label="Open the menu">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 6h18M3 12h18M3 18h18" fill="none" stroke="currentColor" stroke-width="2"/></svg>
</button>
…
</div>
</header>
<nav id="sidebar" class="sidebar" popover aria-label="Documents">
<span class="sidebar-heading">Guides</span>
<a href="/guides/start">Getting started</a>
<details>
<summary>Reference</summary>
<a href="/reference/api">API</a>
<a href="/reference/cli">CLI</a>
</details>
<hr>
<a href="/about/">About</a>
</nav>
<main>…</main>sidebar-headinglabels a group of links.<hr>separates groups.<details>makes a folder. Its links hang from a guide line.- The link to the current page is highlighted by
aria-current="page".sidebar.jssets it on the link whose path and query match the page, and opens the folders around it. sidebar.jsalso closes the popover when a link in it is clicked, and when the window becomes wider than 768px.
Change the width with --sidebar-width (default 240px), the padding on its sides with --sidebar-padding (default 12px), and the colors with --color-sidebar-*. Set --sidebar-width where both the sidebar and <main> can see it, such as :root.
Hero
A large title area at the top of a page. As the first child of <main>, it covers the padding of <main> and fills its width, beside the sidebar. Elsewhere it fills the width of the window. Its background is the page background tinted with 10% of stark. The top of this page is a hero.
Set a background image with --hero-image. A relative URL in a custom property may not be resolved against the page, so use a path from / or a full URL.
.hero-about { --hero-image: url("/images/header/wide.webp"); }
<div class="hero hero-about">
<h1>Title</h1>
<p>Subtitle</p>
</div>Block
An area with a border. Children are stacked with a gap of 16px. With a variant, the border has the color of the alert, and a <b> as the first child is its title. The title is --color-alert-{name}-title-foreground on --color-alert-{name}-title-background, with --alert-title-padding-inline on its sides. The base themes color only the text of the title; the UD themes fill it with the JIS safety color and write it in black (see Themes).
block
block-note
block-tip
block-important
block-warning
block-caution
<div class="block block-note">
<b>Note</b>
<p>Text</p>
</div>On Markdown pages of this site, the alerts of GitHub Markdown become blocks.
> [!WARNING]
> TextLayer
An area with a translucent background. The variants are the same as Block, with a background tinted by the color of the alert.
layer
layer-note
layer-tip
layer-important
layer-warning
layer-caution
A link that contains a block or layer as its child has no underline, so the whole area can be a link.
A layer inside a link.
<a href="/design/">
<div class="layer">…</div>
</a>Details
Content. The space around the content is <details> needs no class. The summary is a bar with a triangle that points up while it is open.Closed
Open
--details-padding (default 16px), and the padding of the summary is --details-summary-padding (default 12px 16px). The colors are --color-details-*.Compact
--details-padding: 8px; --details-summary-padding: 6px 8px
<details>
<summary>Title</summary>
<p>Text</p>
</details>Grid
grid places children in as many equal columns as fit. Each column is at least --grid-min-width (default 160px) wide, and the gap is --grid-gap (default 16px). Set --grid-columns to fix the number of columns.
.cards { --grid-min-width: 240px; }
<div class="grid cards">
<div class="layer">…</div>
<div class="layer">…</div>
</div>Flex
flex lays children out in a row with a gap of 16px. flex:1 to flex:10 set how much of the free space each child takes.
<div class="flex">
<div class="flex:1">…</div>
<div class="flex:2">…</div>
</div>Responsive
hide and show always apply. With a prefix, they apply only at some widths: small: up to 768px, medium: from 769px to 1080px, and large: from 1081px. Resize the window to see them change.
<nav class="small:hide">…</nav>
<button class="hide small:show">…</button>The show classes set display: block. For an element that needs another display, such as flex or grid, combine the *:hide classes instead of hide and *:show.
Spacing
no-padding and no-margin remove the padding or margin. Add -top, -bottom, -left, or -right to remove it on one side only.
layer
no-padding
no-padding-left
<ul class="no-padding-left">…</ul>Other utilities
| Class | Effect |
|---|---|
border | A 1px border in --color-border |
overflow-show, overflow-hide, overflow-scroll | Content that does not fit is drawn outside, clipped, or scrolled |
unselectable | Text cannot be selected |
selectable | Text can be selected again inside an unselectable element |
script-only | Hidden when JavaScript is disabled (with noscript.css) |
overflow-show: content that does not fit is drawn outside the box.
overflow-hide: content that does not fit is clipped, so this line is cut.
overflow-scroll: content that does not fit can be scrolled inside the box.
This text cannot be selected (unselectable).
This text can be selected (selectable).
Priority of utility classes
Utility classes, which each change one property (the classes on this page, fg-color-*, font-weight-*, and so on), are declared with !important. They win over component styles and style attributes, whatever the order or specificity.
block no-padding
Without JavaScript
Pages must work without JavaScript. Load noscript.css inside <noscript>, so that it applies only then. It hides the loading overlay, draws sliders without the fill that slider.js keeps up to date, and hides elements with script-only. Give that class to controls that do nothing without JavaScript, such as buttons that only show toasts.
<noscript><link rel="stylesheet" href="https://assets.nercone.dev/styles/noscript.css"></noscript>
<button class="script-only" type="button" data-toast="Saved">Show toast</button>When JavaScript is enabled but the scripts fail to load, the loading overlay fades out by itself after --loading-overlay-timeout (default 10s), so it does not keep covering the page.