Feedback

Empty State

An empty view that tells you what you can do next.

OSCL StudioComponents, in context.Live preview
FOUNDATION / FEEDBACK

Empty State

Room for something new

Your first project starts with an idea.

Interactive preview. Real components.View docs

Use it in your project

Install oscl-ui from npm and import oscl-ui/styles.css once. See installation.

empty-state-example.tsx
import { EmptyState } from "oscl-ui";

<EmptyState title="Room for something new" description="Create your first project to get started." />

Accessibility

Keep visible labels and keyboard focus. Supply an accessible name to icon-only actions. Try this preview with Tab, Enter, Space, and Escape where appropriate.

The source, in full

This is the actual source from the isolated OSCL package used by this website. Native props and TypeScript declarations are included in the npm package.

empty-state.tsx
"use client";

import type { HTMLAttributes, ReactNode } from "react";

export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
  title: string;
  description: string;
  icon?: ReactNode;
  action?: ReactNode;
}
export function EmptyState({ title, description, icon, action, className = "", ...props }: EmptyStateProps) {
  return <div {...props} className={`oscl-empty ${className}`}>
    {icon && <div className="oscl-empty-icon" aria-hidden="true">{icon}</div>}
    <h3 className="oscl-empty-title">{title}</h3><p className="oscl-empty-description">{description}</p>{action && <div className="oscl-empty-action">{action}</div>}
  </div>;
}