Components
← All components

Empty State Observer

stimeo--empty-state

Shows an empty placeholder when a list has no items and hides it once one arrives.

The stimeo--empty-state controller watches a list with a MutationObserver and toggles between the list and an empty placeholder at the 0 ↔ 1+ item boundary, keeping the consumer from hand-rolling count tracking for Turbo Stream rows. It counts the list's element children (or those matching itemSelector), toggles hidden on the list / empty targets, reflects data-empty and data-count on the controller element, and dispatches stimeo--empty-state:change when the boundary is crossed. With announce, the empty target is made a polite live region (unless the author already set one). Behavior only — the placeholder's look and copy are the consumer's; state is derived from the DOM (no module-scope state) so connect re-syncs after a Turbo Stream insertion, and the observer is severed on disconnect (Turbo navigation included).

running
  • Item 1
  • Item 2