package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/empty" "github.com/axadrn/shadcn-templ/v2/components/icon") templ EmptyDemo() { @empty.Empty() { @empty.Header() { @empty.Media(empty.MediaProps{Variant: empty.MediaVariantIcon}) { @icon.FolderCode() } @empty.Title() { No Projects Yet } @empty.Description() { You haven't created any projects yet. Get started by creating your first project. } } @empty.Content(empty.ContentProps{Class: "flex-row justify-center gap-2"}) { @button.Button() { Create Project } @button.Button(button.Props{Variant: button.VariantOutline}) { Import Project } } @button.Button(button.Props{ Variant: button.VariantLink, Size: button.SizeSm, Href: "#", Class: "text-muted-foreground", }) { Learn More @icon.ArrowUpRight() } }}Installation
Usage
Composition
Use the following composition to build an Empty state:
Outline
Use the border utility class to create an outline empty state.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/empty" "github.com/axadrn/shadcn-templ/v2/components/icon") templ EmptyOutline() { @empty.Empty(empty.Props{Class: "border border-dashed"}) { @empty.Header() { @empty.Media(empty.MediaProps{Variant: empty.MediaVariantIcon}) { @icon.Cloud() } @empty.Title() { Cloud Storage Empty } @empty.Description() { Upload files to your cloud storage to access them anywhere. } } @empty.Content() { @button.Button(button.Props{ Variant: button.VariantOutline, Size: button.SizeSm, }) { Upload Files } } }}Background
Use the bg-* and bg-gradient-* utilities to add a background to the empty state.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/empty" "github.com/axadrn/shadcn-templ/v2/components/icon") templ EmptyBackground() { @empty.Empty(empty.Props{Class: "h-full bg-muted/30"}) { @empty.Header() { @empty.Media(empty.MediaProps{Variant: empty.MediaVariantIcon}) { @icon.Bell() } @empty.Title() { No Notifications } @empty.Description(empty.DescriptionProps{Class: "max-w-xs text-pretty"}) { You're all caught up. New notifications will appear here. } } @empty.Content() { @button.Button(button.Props{Variant: button.VariantOutline}) { @icon.RefreshCcw() Refresh } } }}Avatar
Use the empty.Media component to display an avatar in the empty state.
AApackage examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/avatar" "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/empty") templ EmptyAvatar() { @empty.Empty() { @empty.Header() { @empty.Media(empty.MediaProps{Variant: empty.MediaVariantDefault}) { @avatar.Avatar(avatar.Props{Class: "size-12"}) { @avatar.Image(avatar.ImageProps{ Src: "https://github.com/axadrn.png", Class: "grayscale", }) @avatar.Fallback() { AA } } } @empty.Title() { User Offline } @empty.Description() { This user is currently offline. You can leave a message to notify them or try again later. } } @empty.Content() { @button.Button(button.Props{Size: button.SizeSm}) { Leave Message } } }}Avatar Group
Use the empty.Media component to display an avatar group in the empty state.
AA
AH
JDpackage examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/avatar" "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/empty" "github.com/axadrn/shadcn-templ/v2/components/icon") templ EmptyAvatarGroup() { @empty.Empty() { @empty.Header() { @empty.Media() { @avatar.Group(avatar.GroupProps{Class: "*:data-[slot=avatar]:size-12 grayscale"}) { @avatar.Avatar() { @avatar.Image(avatar.ImageProps{ Src: "https://github.com/axadrn.png", Alt: "@axadrn", }) @avatar.Fallback() { AA } } @avatar.Avatar() { @avatar.Image(avatar.ImageProps{ Src: "https://github.com/a-h.png", Alt: "@a-h", }) @avatar.Fallback() { AH } } @avatar.Avatar() { @avatar.Image(avatar.ImageProps{ Src: "https://github.com/joerdav.png", Alt: "@joerdav", }) @avatar.Fallback() { JD } } } } @empty.Title() { No Team Members } @empty.Description() { Invite your team to collaborate on this project. } } @empty.Content() { @button.Button(button.Props{Size: button.SizeSm}) { @icon.Plus() Invite Members } } }}InputGroup
You can add an inputgroup.InputGroup component to the empty.Content component.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/empty" "github.com/axadrn/shadcn-templ/v2/components/icon" "github.com/axadrn/shadcn-templ/v2/components/inputgroup" "github.com/axadrn/shadcn-templ/v2/components/kbd") templ EmptyInputGroup() { @empty.Empty() { @empty.Header() { @empty.Title() { 404 - Not Found } @empty.Description() { The page you're looking for doesn't exist. Try searching for what you need below. } } @empty.Content() { @inputgroup.InputGroup(inputgroup.Props{Class: "sm:w-3/4"}) { @inputgroup.Input(inputgroup.InputProps{Placeholder: "Try searching for pages..."}) @inputgroup.Addon() { @icon.Search() } @inputgroup.Addon(inputgroup.AddonProps{Align: inputgroup.AlignInlineEnd}) { @kbd.Kbd() { / } } } @empty.Description() { Need help? <a href="#">Contact support</a> } } }}API Reference
Empty
The main component of the empty state. Wraps the empty.Header and empty.Content components.
EmptyHeader
The empty.Header component wraps the empty media, title, and description.
EmptyMedia
Use the empty.Media component to display the media of the empty state such as an icon or an image. You can also use it to display other components such as an avatar.
EmptyTitle
Use the empty.Title component to display the title of the empty state.
EmptyDescription
Use the empty.Description component to display the description of the empty state.
EmptyContent
Use the empty.Content component to display the content of the empty state such as a button, input or a link.