// Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause import cx from "classnames" import React, { cloneElement } from "react" type Props = { action?: React.ReactNode className?: string description: string icon?: React.ReactElement title?: string } /** * EmptyState shows some text and an optional action when some area that can * house content is empty (eg. no search results, empty tables). */ export default function EmptyState(props: Props) { const { action, className, description, icon, title } = props const iconColor = "text-gray-500" const iconComponent = getIcon(icon, iconColor) return (
{icon &&
{iconComponent}
} {title && (

{title}

)}
{description}
{action &&
{action}
}
) } function getIcon(icon: React.ReactElement | undefined, iconColor: string) { return icon ? cloneElement(icon, { className: iconColor }) : null }