Skip to content
W WRNexusJS
feedback component

EmptyState

Reusable empty state component.

@wrnexus/ui 0.2.6712 props0 slots0 events

Usage

Components are auto-discovered. Use the component directly in any .wrn view:

<EmptyState
  eyebrow="eyebrow"
  title="Nothing found"
  description="description"
  iconClass="icon-[lucide--inbox]"
  primaryLabel="primaryLabel"
/>

Legacy mount name: data-component="EmptyState".

Props and attributes

PropTypeRequirementDefault
classstringOptional""
eyebrowstringOptional""
titlestringOptional"Nothing found"
descriptionstringOptional""
iconClassstringOptional"icon-[lucide--inbox]"
primaryLabelstringOptional""
primaryHrefstringOptional""
secondaryLabelstringOptional""
secondaryHrefstringOptional""
compactbooleanOptionalfalse
centeredbooleanOptionaltrue
suggestionsstringOptional[]

Slots

This component does not declare a slot.

Events

This component does not declare a custom event.

Source contract

Installed source: components/EmptyState.wrn

component EmptyState {
    props {
        class: string = ""
        eyebrow = ""
        title = "Nothing found"
        description = ""

        iconClass = "icon-[lucide--inbox]"

        primaryLabel = ""
        primaryHref = ""

        secondaryLabel = ""
        secondaryHref = ""

        compact = false
        centered = true

        suggestions = []
    }

    view {
        <section
            aria-labelledby="empty-state-title"
            class="w-full {class}"
            class:py-6="compact"
            class:sm:py-8="compact"
            class:py-8="!compact"
            class:sm:py-10="!compact"
        >
        <div
                class=" relative mx-auto w-full overflow-hidden rounded-3xl border border-indigo-200/80 bg-linear-to-br from-indigo-50/90 via-white to-violet-50/80 shadow-xl shadow-indigo-950/5 dark:border-indigo-500/20 dark:from-indigo-500/10 dark:via-slate-900 dark:to-violet-500/10 dark:shadow-black/20 "
                class:max-w-3xl="centered"
            >
        <!-- Background decoration -->
        <div
                    aria-hidden="true"
                    class="pointer-events-none absolute inset-0 overflow-hidden"
                >
        <div class="absolute -right-20 -top-24 h-56 w-56 rounded-full bg-indigo-200/30 blur-3xl dark:bg-indigo-500/10">
        </div>
        <div class="absolute -bottom-24 -left-20 h-56 w-56 rounded-full bg-violet-200/20 blur-3xl dark:bg-violet-500/5">
        </div>
        <div class="absolute inset-x-0 top-0 h-px bg-linear-to-r from-transparent via-indigo-300/70 to-transparent dark:via-indigo-500/20">
        </div>
        </div>
        <div
                    class="relative"
                    class:px-6="compact"
                    class:py-8="compact"
                    class:sm:px-8="compact"
                    class:sm:py-9="compact"
                    class:px-6="!compact"
                    class:py-10="!compact"
                    class:sm:px-10="!compact"
                    class:sm:py-12="!compact"
                    class:lg:px-12="!compact"
                    class:text-center="centered"
                >
        <div
                        class=" {compact ? 'max-w-xl' : 'max-w-2xl'} {centered ? 'mx-auto' : 'mr-auto'} "
                        class:max-w-xl="compact"
                        class:max-w-2xl="!compact"
                    >
        <!-- Icon -->
        <div
                            class="flex"
                            class:justify-center="centered"
                        >
        <span
                                class="grid place-items-center rounded-2xl bg-indigo-50 text-indigo-600 ring-1 ring-inset ring-indigo-200 dark:bg-indigo-500/10 dark:text-indigo-300 dark:ring-indigo-500/20"
                                class:h-12="compact"
                                class:w-12="compact"
                                class:h-14="!compact"
                                class:w-14="!compact"
                            >
        <span class="{iconClass}" class:h-5="compact" class:w-5="compact" class:h-6="!compact" class:w-6="!compact" aria-hidden="true" >
        </span>
        </span>
        </div>
        <!-- Eyebrow -->
        <p
                            class="mt-5 text-xs font-bold uppercase tracking-[0.18em] text-indigo-600 dark:text-indigo-400"
                            class:hidden="eyebrow === ''"
                        >
                            {eyebrow}
                        </p>
        <!-- Title -->
        <h2
                            id="empty-state-title"
                            class="font-bold tracking-tight text-slate-950 dark:text-white"
                            class:mt-5="eyebrow === ''"
                            class:mt-3="eyebrow !== ''"
                            class:text-xl="compact"
                            class:leading-tight="compact"
                            class:sm:text-2xl="compact"
                            class:text-2xl="!compact"
                            class:leading-tight="!compact"
                            class:sm:text-3xl="!compact"
                            class:lg:text-[2rem]="!compact"
                        >
                            {title}
                        </h2>
        <!-- Description -->
        <p
                            class="mx-auto mt-3 max-w-xl text-sm leading-6 text-slate-600 dark:text-slate-400"
                            class:hidden="description === ''"
                            class:sm:text-base="!compact"
                            class:sm:leading-7="!compact"
                        >
                            {description}
                        </p>
        <!-- Suggestions -->
        <div
                            class="mt-6 flex flex-wrap gap-2"
                            class:hidden="suggestions.length === 0"
                            class:justify-center="centered"
                        >
                            {#each suggestions.slice(0, 4) as suggestion}
                            <a
                                href="{suggestion.href}"
                                class="inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-600 shadow-sm transition hover:-translate-y-0.5 hover:border-indigo-300 hover:bg-indigo-50 hover:text-indigo-700 dark:border-white/10 dark:bg-white/5 dark:text-slate-300 dark:hover:border-indigo-500/30 dark:hover:bg-indigo-500/10 dark:hover:text-indigo-300"
                            >
        <span class="{suggestion.iconClass} h-3.5 w-3.5" aria-hidden="true" >
        </span>

                                {suggestion.label}
                            </a>
                            {/each}
                        </div>
        <!-- Actions -->
        <div
                            class="flex flex-col gap-3 sm:flex-row"
                            class:mt-7="suggestions.length === 0"
                            class:mt-6="suggestions.length > 0"
                            class:hidden="primaryLabel === '' && secondaryLabel === ''"
                            class:justify-center="centered"
                        >
        <a
                                href="{secondaryHref}"
                                class="h-11 items-center justify-center rounded-xl border border-slate-200 bg-white px-4 text-sm font-semibold text-slate-700 shadow-sm transition hover:-translate-y-0.5 hover:border-indigo-300 hover:bg-slate-50 hover:text-indigo-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:border-indigo-500/30 dark:hover:bg-white/10 dark:hover:text-indigo-300"
                                class:hidden="secondaryLabel === ''"
                                class:inline-flex="secondaryLabel !== ''"
                            >
                                {secondaryLabel}
                            </a>
        <a
                                href="{primaryHref}"
                                class="group h-11 items-center justify-center gap-2 rounded-xl bg-indigo-600 px-4 text-sm font-bold text-white shadow-lg shadow-indigo-600/20 transition hover:-translate-y-0.5 hover:bg-indigo-500 hover:shadow-xl focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-slate-900"
                                class:hidden="primaryLabel === ''"
                                class:inline-flex="primaryLabel !== ''"
                            >
                                {primaryLabel}

                                <span class="icon-[lucide--arrow-right] h-4 w-4 transition-transform group-hover:translate-x-1" aria-hidden="true" >
        </span>
        </a>
        </div>
        </div>
        </div>
        </div>
        </section>
    }
}