:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { Card as QuillCard, CardAction, CardContent, CardHeader, CardTitle } from '@posthog/quill-primitives'
export function Card({
children,
className,
flush = false,
title,
action,
}: {
children: React.ReactNode
className?: string
/** Let a full-bleed child (table, chart) reach the card's edges, with no header-to-content gap. */
flush?: boolean
title?: string
/** Control shown at the top right of the header. */
action?: React.ReactNode
}): JSX.Element {
return (
<QuillCard size="sm" flush={flush} className={className}>
{title ? (
<CardHeader className={action ? 'flex flex-wrap items-start justify-between gap-2' : undefined}>
<CardTitle>{title}</CardTitle>
{action ? <CardAction>{action}</CardAction> : null}
</CardHeader>
) : null}
{/* min-h-0 lets a height-constrained card's content shrink instead of overflowing the card's clip. */}
<CardContent className="flex flex-1 flex-col min-h-0">{children}</CardContent>
</QuillCard>
)
}
// Picks the right card body: a skeleton while the first load is in flight, an empty message when
// there's no data, otherwise the content. Guard clauses instead of a nested ternary at each call site.
export function CardState({
loading,
isEmpty,
skeleton,
empty,
children,
}: {
loading: boolean
isEmpty: boolean
skeleton: React.ReactNode
empty: React.ReactNode
children: React.ReactNode
}): JSX.Element {
if (loading && isEmpty) {
return <>{skeleton}</>
}
if (isEmpty) {
return <>{empty}</>
}
return <>{children}</>
}