Skip to content
IndexRequest a UIAboutContact

Empty State with Action

A list that explains why it is empty and offers one clear action; add items to fill it and clear to see it again.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a task list component with a designed empty state. When empty: a simple line-art checklist icon, the heading "No tasks yet", the text "Add your first task to start planning your day." and a primary "Add task" button. After adding, tasks appear as rows with a checkbox and text; a small "Clear all" text button returns to the empty state. Light minimal style, rounded 12 pixel card, 1 pixel border, centred empty content, buttons at least 32 pixel tall. Announce additions with aria-live polite and keep focus on the Add button. Provide a prefers-reduced-motion fallback. Plain HTML, CSS and JavaScript.

About this pattern

Definition

An empty state replaces a blank area when there is nothing to show yet. A good one says what belongs here, why it is empty and what to do next.

Purpose & UX principles

  • First-run empties should teach: one line on the benefit, one primary action.
  • Search or filter empties should say nothing matched and offer to clear the filter.
  • Avoid humour that hides the instruction; keep the illustration light and decorative.

Interaction states

  • Empty (message and action), populated (list with a Clear all action), and the transition between them.

Motion specification

  • Items slide in 200ms; the empty message fades out 150ms.
  • Reduced motion: items appear without sliding.

Responsive behaviour

  • Centre the content in the container; keep the message under two lines and the button reachable with one thumb.
  • Do not reserve large illustration space on small screens.

Code

HTML
<div class="bx"><div class="card"><div class="empty" id="em"><svg viewBox="0 0 48 48" width="40" height="40" aria-hidden="true" fill="none" stroke="#9a9a94" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="6" width="30" height="36" rx="4"/><path d="M16 16l3 3 5-6M16 28h16M16 35h10"/></svg><h2>No tasks yet</h2><p>Add your first task to start planning your day.</p></div><ul class="ls" id="ls" aria-live="polite"></ul></div>
<div class="act"><button id="add" type="button">Add task</button><button id="clr" type="button" hidden>Clear all</button></div></div>

Related patterns

Skeleton Loading

↗
Skeleton LoadingLoading & Progress

Inline Alert Banners

↗
Inline Alert BannersFeedback & Notifications

Toast

↗
ToastFeedback & Notifications