GlassKit UI
Primitives

EmptyState

The nothing-here screen: optional glyph + title + hint + one action. The quiet sibling of ErrorState: nothing failed, there's just no content yet. Pairs with AsyncView's placeholder slot.

No photos yet

Photos you capture show up here.

Nothing here yet

Installation

npx @glasskit-ui/cli add empty-state

Install the SDK (it provides GlassViewport, useDpad and the stylesheet), then copy these files into your project:

npm install @glasskit-ui/react
// components/lib/utils.tsimport { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";export type { ClassValue };/** * Merge class names the shadcn way: clsx joins conditionals, tailwind-merge * de-dupes conflicting Tailwind utilities so a consumer's `className` override * wins (e.g. passing `px-2` beats the component's `px-6`). Lens components are * Tailwind utilities + `--gk-*` tokens, so this de-dupe matters. */export function cn(...inputs: ClassValue[]): string {  return twMerge(clsx(inputs));}/** * Accessible name from a free-form `label` prop: the label itself when it's a * plain string, otherwise undefined (a ReactNode can't become an aria-label). */export function stringLabel(label: unknown): string | undefined {  return typeof label === "string" ? label : undefined;}
// components/glasskit/button.tsximport type { ReactNode } from "react";import { cn } from "../lib/utils";/** * <Button> — a D-pad-focusable action. Renders a real <button> carrying * the `focusable` class, so `useDpad()` includes it in spatial navigation * and activates it on Enter/Space (the hook calls `.click()`, which fires * `onClick`). `primary` wears the accent fill; `positive`/`danger` carry the * semantic accept/destroy fills (calls, irreversible confirms); `ghost` is * chrome-less (just text + focus ring + press) for toolbars and icon rows. */export function Button({  children,  variant = "secondary",  icon,  disabled,  onClick,  type = "button",  initialFocus = false,  "aria-label": ariaLabel,  className,}: {  /** The label. Omit for an icon-only button, but then set `aria-label`. */  children?: ReactNode;  variant?: "primary" | "secondary" | "ghost" | "positive" | "danger";  /** Optional leading glyph — typically a <Icon>. */  icon?: ReactNode;  disabled?: boolean;  onClick?: () => void;  type?: "button" | "submit" | "reset";  /** Seed the D-pad ring here when the screen mounts (`data-autofocus`). */  initialFocus?: boolean;  /** Accessible name — required for an icon-only button. */  "aria-label"?: string;  className?: string;}) {  return (    <button      type={type}      disabled={disabled}      onClick={onClick}      aria-label={ariaLabel}      data-autofocus={initialFocus || undefined}      className={cn(        "focusable press-scale t-body inline-flex items-center justify-center gap-2 rounded-2xl",        variant === "primary"          ? "btn-primary"          : variant === "positive"            ? "btn-positive"            : variant === "danger"              ? "btn-danger"              : variant === "ghost"                ? "bg-transparent border-0 text-foreground"                : "surface",        !children ? "p-[13px] [&_svg]:size-[22px]" : "px-6 py-4",        className,      )}    >      {icon}      {children}    </button>  );}
// components/glasskit/empty-state.tsximport type { ReactNode } from "react";import { cn } from "../lib/utils";import { Button } from "./button";/** * <EmptyState> — the nothing-here screen: optional glyph + title + hint + one * action. The quiet sibling of <ErrorState> — nothing failed, there is just no * content yet, so it reads dimmer and the action invites rather than recovers. * Drop it into a <Screen> stage, or use it as the `placeholder` slot of * <AsyncView>. */export function EmptyState({  title = "Nothing here yet",  hint,  icon,  onAction,  actionLabel = "Refresh",  className,}: {  title?: ReactNode;  /** A quieter second line — what will fill this screen, or how. */  hint?: ReactNode;  /** Optional leading glyph — typically a <Icon>. */  icon?: ReactNode;  onAction?: () => void;  actionLabel?: ReactNode;  className?: string;}) {  return (    <div      className={cn(        "flex flex-col items-center gap-3.5 text-center",        className,      )}    >      {icon}      <p className="t-title text-muted-foreground">{title}</p>      {hint != null ? (        <p className="t-body max-w-[30ch] text-foreground-faint">{hint}</p>      ) : null}      {onAction ? <Button onClick={onAction}>{actionLabel}</Button> : null}    </div>  );}

Usage

<EmptyState  title="No messages"  hint="New conversations land here."  onAction={refetch}/>// as AsyncView's placeholder<AsyncView status={status} placeholder={<EmptyState title="No workouts" />}>  {data}</AsyncView>

Props

PropTypeDefaultDescription
titleReactNode"Nothing here yet"The headline.
hintReactNodeA quieter second line: what will fill this screen, or how.
iconReactNodeOptional leading glyph.
onAction() => voidShows an action button when set.
actionLabelReactNode"Refresh"Action button label.

On this page