Skip to component content
Collection063 / 155

EmptyState

Explain an empty collection and offer a useful next action.

Example

No field notes yet

Record observations from the garden.

Source
EmptyState.tsxtsx
import { useState } from "react";
import { NotebookIcon } from "@phosphor-icons/react";
import { Button, EmptyState, Text, VStack } from "@/ohmygui";

export default function Example() {
  const [created, setCreated] = useState(false);
  return (
    <VStack gap="md">
      {created ? (
        <Text as="p" role="status">
          Your first note is ready.
        </Text>
      ) : (
        <EmptyState
          title="No field notes yet"
          description="Record observations from the garden."
          action={<Button onClick={() => setCreated(true)}>Add a note</Button>}
        >
          <NotebookIcon size={32} aria-hidden="true" />
        </EmptyState>
      )}
    </VStack>
  );
}