SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Empty

A placeholder for a product section that has nothing to show, typed by why.

INV-2041

Northwind Traders

$4,200.00
INV-2042

Contoso

$1,150.00
INV-2043

Fabrikam

$780.00
View code
tsx
let query = "";
let matches = INVOICES.filter((invoice) =>
	`${invoice.id} ${invoice.client}`.toLowerCase().includes(query.trim().toLowerCase()),
);

<Group>
	<Input
		name="q"
		type="search"
		value={query}
		placeholder="Search invoices"
		aria-label="Search invoices"
		mix={[
			on<HTMLInputElement, "input">("input", (event) => {
				query = event.currentTarget.value;
				void handle.update();
			}),
		]}
	/>
</Group>

{matches.length > 0 ? (
	matches.map((invoice) => (
		<Item key={invoice.id}>
			<Item.Media>
				<FileTextIcon aria-hidden="true" />
			</Item.Media>
			<Item.Content>
				<Item.Title>{invoice.id}</Item.Title>
				<Item.Description>{invoice.client}</Item.Description>
			</Item.Content>
			<Item.Actions>{invoice.amount}</Item.Actions>
		</Item>
	))
) : (
	<Empty>
		<Empty.Icon>
			<SearchIcon />
		</Empty.Icon>
		<Empty.Title>No invoices match “{query.trim()}”</Empty.Title>
		<Empty.Description>
			Search runs over the invoice number and the client's name. Nothing in this workspace
			matches either.
		</Empty.Description>
		<Empty.Action>
			<Button variant="outline" color="neutral" mix={[on("click", clearQuery)]}>
				Clear the search
			</Button>
			<Button>New invoice</Button>
		</Empty.Action>
	</Empty>
)}

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the showcase.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { Empty } from "@sdxc/ui/app";

Renders the empty-state panel, a column tinted to its color role. A kind leads with its own icon and frame: a dashed outline for a first run, no frame for no results or a cleared list, a solid one for permission or error.

Composition

The parts the component publishes, each a static property of the host.

  • Empty
  • Empty.IconRenders Empty.IconProps.children as the icon well: a fully rounded, tinted badge framing an icon graphic hidden from assistive technology, since Empty.Title's text already names the state.
  • Empty.TitleRenders Empty.TitleProps.children as the empty state's heading, in the native heading element matching its ambient HeadingScope depth (or <h1> unscoped), sized as the panel's primary text regardless of level.
  • Empty.DescriptionRenders Empty.DescriptionProps.children as the empty state's supporting copy, in a native <p> set to seventy percent of the panel's current text color so it reads as secondary to Empty.Title.
  • Empty.ActionRenders Empty.ActionProps.children as the empty state's call-to-action slot: a centered, wrapping row spaced a touch below the text above it, so a state offering more than one action lays them out rather than running them together.
  • Empty.QueryRenders the reader's query inside a no-results description as a native <q>, so the browser adds the locale's own quotation marks around it and the reader sees exactly what to change.
  • Empty.RequestIdRenders an error state's request id line: a label such as "Request ID", then the Empty.RequestIdValue, in small muted text.
  • Empty.RequestIdValueThe failed request's id in monospace that selects whole on one click, so the reader can copy it into a support message without a script.

Examples

First run

Create your first monitor

Monitors check a URL every minute and tell you when it stops answering.

View code
tsx
<Empty kind="first-run">
	<Empty.Title>Create your first monitor</Empty.Title>
	<Empty.Description>
		Monitors check a URL every minute and tell you when it stops answering.
	</Empty.Description>
	<Empty.Action>
		<Button>Create Monitor</Button>
	</Empty.Action>
</Empty>

No results

No monitors match

Nothing matched status:down region:fra. Try another region.

View code
tsx
<Empty kind="no-results">
	<Empty.Title>No monitors match</Empty.Title>
	<Empty.Description>
		Nothing matched <Empty.Query>status:down region:fra</Empty.Query>. Try another region.
	</Empty.Description>
	<Empty.Action>
		<Button variant="outline">Clear filters</Button>
	</Empty.Action>
</Empty>

All caught up

All caught up

No open incidents. New ones land here as they start.

View code
tsx
<Empty kind="cleared">
	<Empty.Title>All caught up</Empty.Title>
	<Empty.Description>No open incidents. New ones land here as they start.</Empty.Description>
</Empty>

No permission

Billing is for owners

Ask Ana Ruiz, the team owner, to give you access.

View code
tsx
<Empty kind="permission">
	<Empty.Title>Billing is for owners</Empty.Title>
	<Empty.Description>Ask Ana Ruiz, the team owner, to give you access.</Empty.Description>
</Empty>

Error

Couldn't load incidents

The server took too long to answer. Try again.

Request ID req_01JD8Z3K4R7Y2M

View code
tsx
<Empty kind="error">
	<Empty.Title>Couldn't load incidents</Empty.Title>
	<Empty.Description>The server took too long to answer. Try again.</Empty.Description>
	<Empty.Action>
		<Button variant="outline">Retry</Button>
	</Empty.Action>
	<Empty.RequestId>
		Request ID <Empty.RequestIdValue>req_01JD8Z3K4R7Y2M</Empty.RequestIdValue>
	</Empty.RequestId>
</Empty>

Compact, inside a card

No failing checks

Every monitor answered in the last hour.

View code
tsx
<Card>
	<Card.Content>
		<Empty kind="cleared" size="compact">
			<Empty.Title>No failing checks</Empty.Title>
			<Empty.Description>Every monitor answered in the last hour.</Empty.Description>
		</Empty>
	</Card.Content>
</Card>

Danger color

We could not find that project

View code
tsx
<Empty color="danger">
	<Empty.Title>We could not find that project</Empty.Title>
</Empty>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
color"brand" | "neutral" | "success" | "warning" | "danger"—NoSemantic tone of the panel. Default: the kind's tone, else "neutral".
kind"first-run" | "no-results" | "cleared" | "permission" | "error"—NoWhy it is empty; draws that cause's icon, tone and frame. An Empty.Icon among the children takes the default icon's place, and a hidden one leaves none.
size"default" | "compact"—NoDefault: "default".
childrenRemixNode—YesThe panel's compound parts: Empty.Icon, Empty.Title, Empty.Description, Empty.Action, or any other content.

Also accepts everything in TagProps<"div">.

Empty.Icon

PropTypeDefaultRequiredDescription
childrenRemixNode—NoIcon graphic rendered inside the icon well.

Also accepts everything in TagProps<"div">.

Empty.Title

PropTypeDefaultRequiredDescription
childrenRemixNode—YesHeading copy for the empty state.

Also accepts everything in TagProps<"h1">.

Empty.Description

PropTypeDefaultRequiredDescription
childrenRemixNode—YesSupporting copy elaborating on the empty state.

Also accepts everything in TagProps<"p">.

Empty.Action

PropTypeDefaultRequiredDescription
childrenRemixNode—YesCall-to-action content, typically a button or link.

Also accepts everything in TagProps<"div">.

Empty.Query

PropTypeDefaultRequiredDescription
childrenRemixNode—YesThe search text or filter the reader typed, verbatim.

Also accepts everything in TagProps<"q">.

Empty.RequestId

PropTypeDefaultRequiredDescription
childrenRemixNode—YesA label such as "Request ID", then the Empty.RequestIdValue.

Also accepts everything in TagProps<"p">.

Empty.RequestIdValue

Also accepts everything in TagProps<"code">.

Types

NameValuesWhat it decides
Color"brand" | "neutral" | "success" | "warning" | "danger"Semantic tone driving the panel's border, tint, and foreground color through the --ui-* variables for that color.
Kind"first-run" | "no-results" | "cleared" | "permission" | "error"Why the section is empty: first-run (welcome, one create action), no-results (quote the query, offer Clear filters), cleared ("All caught up"), permission (name who grants access), error (Retry and the request id).
Size"default" | "compact""compact" tightens the panel and drops its frame, so it sits flush inside a card or a table body.
@sdxc/ui

Can’t find it? Contact us