-
Notifications
You must be signed in to change notification settings - Fork 9
Guide Recipes EmptyState
MeowLynxSea edited this page Jun 18, 2026
·
3 revisions
The "no data" / "no results" pattern using empty_state. Skip the parent component's normal render and show the empty state as a full panel.
use yororen_ui::ActionVariantKind;
use yororen_ui::headless::button::button;
use yororen_ui::headless::empty_state::empty_state;
use yororen_ui::headless::icon::IconSource;
if self.projects.is_empty() {
return div().size_full().flex().flex_col().items_center().justify_center().p_6().gap_3()
.child(empty_state("projects-empty", &mut *cx)
.icon(IconSource::Builtin("info".into()))
.title("No projects yet")
.description("Create your first project to get started.")
.render(cx))
.child(button("projects-create", cx)
.variant(ActionVariantKind::Primary)
.on_click(|_, _, _| { /* dispatch create flow */ })
.render(cx).child("New project"));
}
div().child(/* … the projects list … */)The cleanest shape is to branch at the parent level — render empty_state when the data is empty, otherwise render the list. Don't render an empty virtual_list (gpui's underlying list refuses to lay out an empty range):
if items.is_empty() {
return div().child(empty_state("list-empty", &mut *cx).title("Nothing here yet").render(cx));
}
virtual_list("items", &controller, cx).row(/* … */).render(cx)empty_state.icon(...) accepts any IconSource:
-
IconSource::Builtin("info".into())— resolves to one of the 20+ bundled icons inyororen-ui-core/assets/icons/. -
IconSource::Resource("my/empty.svg".into())— a path through your application'sAssetSource(registered viaApplication::new().with_assets(...)). Use this for app-specific illustrations.
- EmptyState — full API.
- Recipe: search + results.
Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.