COMPONENTS/FEEDBACK

Empty state.

Nothing here. A useful next step.

In practice

Good things start here.

Add your first project to get going.

Compose a heading, explanatory text and a relevant action. Do not use an empty state for loading or errors.

Installation

Install Coal once. Components and TypeScript declarations are included. React 19 and React DOM 19 are peer dependencies.

Terminal · local package
npm install http://localhost:3100/downloads/chlohal-coal-ui-0.5.0.tgz

This installs the local package. It is not yet published on npm. See installation for stylesheet setup and integration.

Usage

example.tsx
"use client";
import * as React from "react";
import "@chlohal/coal-ui/styles.css";
import { Plus } from "lucide-react";
import { Button, Empty } from "@chlohal/coal-ui";
export default function Example() {
    const [files, setFiles] = React.useState<string[]>([]);
    return files.length ? (<div role="status">
          {files.map((f) => (<p key={f}>{f}</p>))}
        </div>) : (<Empty>
          <span />
          <p>Good things start here.</p>
          <p>Add your first project to get going.</p>
          <Button size="sm" variant="outline" onClick={() => setFiles(["Untitled project"])}>
            <Plus />
            New project
          </Button>
        </Empty>);
}

Source

The original Coal implementation. Use the package export to integrate it.

packages/react/src/empty.tsx
import * as React from "react";
import { cn } from "./internal.js";
export type EmptyProps = React.ComponentPropsWithRef<"div">;
export function Empty({ className, ...props }: EmptyProps) {
  return <div className={cn("coal-empty", className)} {...props} />;
}

Accessibility checklist

  • Provide an accessible name for controls, including icon-only buttons.
  • Check keyboard navigation, visible focus and disabled states in your application.
  • Do not rely on color alone to communicate status.