# Empty Explain why a view has no content and give the user a relevant next action. [Interactive guide](/docs/components/empty) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use Empty for a view that loaded successfully and has no content or no matching results. ### How to compose it Use EmptyHeader with title and cause, then EmptyContent for a relevant next action or filter reset. Use EmptyMedia only when it clarifies the state. ### What to verify Test both an untouched empty collection and a filter with zero results. Verify the action addresses the cause displayed. ## Usage ```tsx import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from 'wss3-forge' ``` - All six parts are available in wss3-forge. The Base UI, Radix and React Aria entries re-export the same HTML components. - Compose a short EmptyTitle and EmptyDescription in EmptyHeader. Add EmptyMedia for an icon, avatar or avatar group and EmptyContent for actions or an input. - EmptyMedia variant="icon" supplies a compact neutral icon background. The default variant preserves the dimensions of arbitrary media. Empty supports default, outline and background surfaces. - Use EmptyContent direction="row" for related actions. Keep one primary action. Set the title level to fit the surrounding document. ## Runnable examples ### No projects ```tsx import { useId, useRef, useState } from 'react' import { FolderOpen20Regular } from '@fluentui/react-icons' import { Button, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Input, Link, Text, VStack } from 'wss3-forge' function ProjectEmpty({ rtl = false }: { rtl?: boolean }) { const [open, setOpen] = useState(false) const [project, setProject] = useState('') const [error, setError] = useState('') const chooser = useRef(null) const form = useId() if (project) return {project} return {rtl ? 'لا توجد موجزات مشاريع' : 'No project briefs'} {rtl ? 'أنشئ موجزًا لعملية الطباعة القادمة أو استورده من ملف JSON.' : "Create a brief for your next print run, or import one from a JSON file."} { const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return try { const data: unknown = JSON.parse(await file.text()) if (!data || typeof data !== 'object' || !('name' in data) || typeof data.name !== 'string' || !data.name.trim()) throw new Error() setError('') setProject(data.name.trim()) } catch { setError(rtl ? 'اختر ملف JSON يحتوي على اسم مشروع.' : 'Choose a JSON file with a project name in its name property.') } }} /> {error && {error}} {rtl ? 'دليل إعداد المشروع' : 'Project setup guide'} {rtl ? 'إنشاء مشروع' : 'Create project'}{rtl ? 'اختر اسمًا لمشروعك.' : 'Give your project a name.'}
{ event.preventDefault(); const name = String(new FormData(event.currentTarget).get('name') ?? '').trim() if (name) { setOpen(false); setProject(name) } }}>
{rtl ? 'إلغاء' : 'Cancel'}
} export default function Example() { return () } ``` ### Outline ```tsx import { useRef, useState } from 'react' import { Cloud20Regular } from '@fluentui/react-icons' import { Button, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from 'wss3-forge' function StorageEmpty() { const chooser = useRef(null) const [files, setFiles] = useState([]) return {files.length ? 'Selected files' : 'No reference files'} {files.length ? files.join(', ') : 'Choose files from your device to attach to this brief.'} setFiles(Array.from(event.currentTarget.files ?? [], file => file.name))} /> } export default function Example() { return () } ``` ### Background ```tsx import { useState } from 'react' import { Alert20Regular, ArrowClockwise16Regular } from '@fluentui/react-icons' import { Button, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from 'wss3-forge' function NotificationsEmpty() { const [checked, setChecked] = useState(false) return Your review queue is clear{checked ? 'Checked just now. No proofs are waiting for review.' : 'Proofs appear here when someone requests your review.'} } export default function Example() { return () } ``` ### Avatar ```tsx import { useId, useState } from 'react' import { Add16Regular } from '@fluentui/react-icons' import { Avatar, AvatarGroup, Button, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Input } from 'wss3-forge' function PersonEmpty({ team = false }: { team?: boolean }) { const [open, setOpen] = useState(false) const [entry, setEntry] = useState('') const form = useId() return {team ? {['Rina Shah', 'Jon Bell', 'Lena Park'].map(name => )} : } {team ? 'No reviewers assigned' : 'Rina is away'} {entry ? (team ? 'Invitation prepared for ' : 'Message draft saved: ') + entry : team ? 'Choose a reviewer to invite to the next proof.' : 'Save a note for Rina to read when she returns to the studio.'} {team ? 'Prepare invitation' : 'Leave a message'} {team ? 'Enter the email address for an invitation draft.' : 'Write a message to save as a draft.'}
{ event.preventDefault(); setEntry(String(new FormData(event.currentTarget).get('entry'))); setOpen(false) }}>
Cancel
} export default function Example() { return () } ``` ### Avatar group ```tsx import { useId, useState } from 'react' import { Add16Regular } from '@fluentui/react-icons' import { Avatar, AvatarGroup, Button, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Input } from 'wss3-forge' function PersonEmpty({ team = false }: { team?: boolean }) { const [open, setOpen] = useState(false) const [entry, setEntry] = useState('') const form = useId() return {team ? {['Rina Shah', 'Jon Bell', 'Lena Park'].map(name => )} : } {team ? 'No reviewers assigned' : 'Rina is away'} {entry ? (team ? 'Invitation prepared for ' : 'Message draft saved: ') + entry : team ? 'Choose a reviewer to invite to the next proof.' : 'Save a note for Rina to read when she returns to the studio.'} {team ? 'Prepare invitation' : 'Leave a message'} {team ? 'Enter the email address for an invitation draft.' : 'Write a message to save as a draft.'}
{ event.preventDefault(); setEntry(String(new FormData(event.currentTarget).get('entry'))); setOpen(false) }}>
Cancel
} export default function Example() { return () } ``` ### Input group ```tsx import { useEffect, useRef, useState } from 'react' import { Search16Regular } from '@fluentui/react-icons' import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle, InputGroup, InputGroupAddon, InputGroupInput, Kbd, Link, Text, VStack } from 'wss3-forge' const pages = [{ title: 'Installation', path: '/docs/installation' }, { title: 'Components', path: '/docs/components' }, { title: 'Empty', path: '/docs/components/empty' }] function MissingPage() { const [query, setQuery] = useState('') const search = useRef(null) useEffect(() => { function focus(event: KeyboardEvent) { if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey || (event.target instanceof HTMLElement && event.target.closest('input,textarea,select,[contenteditable="true"]'))) return const frame = search.current?.getBoundingClientRect() if (frame && frame.bottom > 0 && frame.top < window.innerHeight) { event.preventDefault(); search.current?.focus() } } document.addEventListener('keydown', focus) return () => document.removeEventListener('keydown', focus) }, []) const results = pages.filter(page => page.title.toLowerCase().includes(query.trim().toLowerCase())) return Page unavailableThis page may have moved. Search the documentation for its new location. setQuery(event.target.value)} placeholder="Search the docs…" /> / {query.trim() && (results.length ? {results.map(page => {page.title})} : No matching pages.)} Or browse all components } export default function Example() { return () } ``` ### RTL ```tsx import { useId, useRef, useState } from 'react' import { FolderOpen20Regular } from '@fluentui/react-icons' import { Button, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Input, Link, Text, VStack } from 'wss3-forge' function ProjectEmpty({ rtl = false }: { rtl?: boolean }) { const [open, setOpen] = useState(false) const [project, setProject] = useState('') const [error, setError] = useState('') const chooser = useRef(null) const form = useId() if (project) return {project} return {rtl ? 'لا توجد موجزات مشاريع' : 'No project briefs'} {rtl ? 'أنشئ موجزًا لعملية الطباعة القادمة أو استورده من ملف JSON.' : "Create a brief for your next print run, or import one from a JSON file."} { const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return try { const data: unknown = JSON.parse(await file.text()) if (!data || typeof data !== 'object' || !('name' in data) || typeof data.name !== 'string' || !data.name.trim()) throw new Error() setError('') setProject(data.name.trim()) } catch { setError(rtl ? 'اختر ملف JSON يحتوي على اسم مشروع.' : 'Choose a JSON file with a project name in its name property.') } }} /> {error && {error}} {rtl ? 'دليل إعداد المشروع' : 'Project setup guide'} {rtl ? 'إنشاء مشروع' : 'Create project'}{rtl ? 'اختر اسمًا لمشروعك.' : 'Give your project a name.'}
{ event.preventDefault(); const name = String(new FormData(event.currentTarget).get('name') ?? '').trim() if (name) { setOpen(false); setProject(name) } }}>
{rtl ? 'إلغاء' : 'Cancel'}
} export default function Example() { return () } ``` ### Compact empty state ```tsx import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from 'wss3-forge' export default function Example() { return ( No saved searchesSaved searches appear here. ) } ``` ## Root package API ### Empty Explain why a view has no content and give the user a relevant next action. Props type: `EmptyProps` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes **Composition exports** - `EmptyContent` (named export) - `EmptyDescription` (named export) - `EmptyHeader` (named export) - `EmptyMedia` (named export) - `EmptyTitle` (named export) - `variant?` — `'default' | 'outline' | 'background'` Default `'default'`. Options `"default"`, `"outline"`, `"background"`. Leave the surface open, add a dashed boundary, or fill its background. - `ref?` — `React.LegacyRef | undefined` ### EmptyContent Props type: `EmptyContentProps` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes - `direction?` — `'column' | 'row'` Default `'column'`. Options `"row"`, `"column"`. Stack controls or arrange related actions in a wrapping row. - `ref?` — `React.LegacyRef | undefined` ### EmptyDescription Props type: `HTMLAttributes` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### EmptyHeader Props type: `HTMLAttributes` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### EmptyMedia Props type: `EmptyMediaProps` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes - `variant?` — `'default' | 'icon' | null` Default `'default'`. Options `null`, `"default"`, `"icon"`. Use icon for a small neutral tile. The default keeps avatars and images at their own size. - `ref?` — `React.LegacyRef | undefined` ### EmptyTitle Props type: `EmptyTitleProps` Native attributes: AriaAttributes, DOMAttributes, HTMLAttributes - `level?` — `1 | 2 | 3 | 4 | 5 | 6` Default `3`. Options `1`, `2`, `3`, `4`, `5`, `6`. Heading level in the surrounding page. - `ref?` — `React.LegacyRef | undefined` ## Related types ```ts export interface EmptyProps extends HTMLAttributes { variant?: 'default' | 'outline' | 'background' } export interface EmptyContentProps extends HTMLAttributes { direction?: 'column' | 'row' } export interface EmptyMediaProps extends HTMLAttributes { variant?: 'default' | 'icon' | null } export interface EmptyTitleProps extends HTMLAttributes { level?: 1 | 2 | 3 | 4 | 5 | 6 } ``` ## Optional primitive contracts - [wss3-forge/base-ui · Empty contract](/ai/skill/primitive-api/Empty.json) - [wss3-forge/radix · Empty contract](/ai/skill/primitive-api/Empty.json) - [wss3-forge/react-aria · Empty contract](/ai/skill/primitive-api/Empty.json)