Empty State¶
Three ways to show an empty region, a boxed message, a compact message, and a small dimmed line. A List, and every component built on it, shows its own empty text.
Decision¶
| When | Use |
|---|---|
| A list with no rows yet | shared.emptySection |
| A list built with a List, a Filtered List, or a table built on one | The List's emptyText |
Usage¶
<div class="stolon-empty-section">No servers yet. Add one below.</div>
<div class="stolon-empty">No records yet</div>
<div class="stolon-empty-inline">This folder is empty.</div>
container.innerHTML = shared.emptySection('No source users available.');
container.innerHTML = shared.emptySection('No records yet', { inline: true });
Classes: stolon-empty-section, stolon-empty, stolon-empty-inline. A List's own empty text is stolon-list-empty.
States and Modifiers¶
shared.emptySection(message, opts)returns adivwith the message escaped. It isstolon-empty-section, or the compactstolon-emptywith{ inline: true }.stolon-empty-sectionis a bordered box with centered, faded text. Its border mixes--stolon-fg.stolon-empty-inlineis a small dimmed line for a region that is not a List, and hides with thehiddenattribute.
Gotchas¶
- Only
emptySectionhas a helper.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
| Class | What it looks like |
|---|---|
stolon-empty-section |
Bordered box with centered muted text for an empty region |
stolon-empty-inline |
Small dimmed line that says a region holds nothing yet, for a region that is not a List |
stolon-empty |
Compact dimmed message for an empty list |
Example¶
Example Code¶
<!-- title: Empty State -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const shared = base.createShared(document.getElementById('view'), 'preview-plugin', 'Preview');
const mount = document.getElementById('mount');
mount.innerHTML =
shared.emptySection('No servers yet. Add one below.') +
'<div style="height: 12px"></div>' +
shared.emptySection('No records yet', { inline: true });
</script>