Components
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.
Installation
npx @glasskit-ui/cli add empty-stateInstall the SDK (it provides GlassViewport, useDpad and the stylesheet), then copy these files into your project:
npm install @glasskit-ui/react// components/lib/utils.tsexport type ClassValue = string | number | null | undefined | false;/** * Join truthy class names. Dependency-free on purpose: the lens components * style via bespoke semantic classes (no conflicting Tailwind utilities to * de-dupe), so this needs no clsx/tailwind-merge and resolves from anywhere * the registry is vendored. */export function cn(...inputs: ClassValue[]): string { return inputs.filter(Boolean).join(" ");}/** * 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`). Edge + focus ring come from the additive `.focusable` recipe; * `primary` brightens the edge — no fills (apple-feel §9). */export function Button({ children, variant = "secondary", icon, disabled, onClick, type = "button", initialFocus = false, className,}: { children: ReactNode; variant?: "primary" | "secondary"; /** Optional leading glyph — typically a <GlowIcon>. */ icon?: ReactNode; disabled?: boolean; onClick?: () => void; type?: "button" | "submit" | "reset"; /** Seed the D-pad ring here when the screen mounts (`data-autofocus`). */ initialFocus?: boolean; className?: string;}) { return ( <button type={type} disabled={disabled} onClick={onClick} data-autofocus={initialFocus || undefined} className={cn( "focusable gk-btn t-body", variant === "primary" && "gk-btn--primary", 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 <GlowIcon>. */ icon?: ReactNode; onAction?: () => void; actionLabel?: ReactNode; className?: string;}) { return ( <div className={cn("gk-emptystate", className)}> {icon} <p className="gk-emptystate__title t-title">{title}</p> {hint != null ? ( <p className="gk-emptystate__hint t-body">{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
Prop
Type
AsyncView
The four-state async renderer every data screen needs: placeholder → loading → success / error. You own the async work and pass the status; AsyncView picks the view, with lens-ready defaults.
ErrorState
A recoverable error screen: optional glyph + title + message + a retry action. No red — the lens has one accent, so the failure reads from the words. Pairs with AsyncView's error slot.