Skip to content

UEmpty: add loading state / loading prop #6645

Description

@stijns96

Feature request

Problem

When fetching async data, there's no built-in way to show a loading state that matches the UEmpty component's visual style. The typical pattern is to either:

  • Show nothing while pending (causes layout shifts)
  • Show the empty state immediately (causes a flash before data arrives)
  • Roll a custom spinner that doesn't match the component system

Proposed solution

Two complementary approaches would solve this:

1. A loading prop on UEmpty

<UEmpty
  icon="i-lucide-message-circle"
  title="Nog geen berichten"
  description="Wees de eerste om iets te zeggen!"
  :loading="status === 'pending'"
/>

When loading is true, the component could replace (or animate) the icon with a spinner and optionally swap the title/description for a loading message.

2. A dedicated ULoading (or USkeleton variant) component

A standalone empty-state-style loading component with the same layout/spacing as UEmpty, so you can toggle between them without layout shifts:

<ULoading v-if="status === 'pending'" />
<UEmpty v-else-if="!items?.length" ... />

Current workaround

<div v-if="status === 'pending'" class="h-full content-center">
  <div class="flex justify-center">
    <UIcon name="i-lucide-loader-circle" class="text-muted size-6 animate-spin" />
  </div>
</div>
<UEmpty v-else-if="!items?.length" ... />

This works but requires manual layout matching and breaks the component abstraction.

Alternatives considered

  • Using USkeleton directly — doesn't match the centered empty-state layout
  • Wrapping in a custom component — adds boilerplate every time this pattern is needed

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions