Home / Function/ TooltipDemo() — ui Function Reference

TooltipDemo() — ui Function Reference

Architecture documentation for the TooltipDemo() function in chart-tooltip-demo.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  40c0e583_c38a_7fb3_4c78_ac28c568dafd["TooltipDemo()"]
  178b777d_82da_4ff7_06b9_c2cddfefbafd["chart-tooltip-demo.tsx"]
  40c0e583_c38a_7fb3_4c78_ac28c568dafd -->|defined in| 178b777d_82da_4ff7_06b9_c2cddfefbafd
  style 40c0e583_c38a_7fb3_4c78_ac28c568dafd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/registry/new-york/examples/chart-tooltip-demo.tsx lines 126–218

function TooltipDemo({
  indicator = "dot",
  label,
  payload,
  hideLabel,
  hideIndicator,
  className,
}: {
  label: string
  hideLabel?: boolean
  hideIndicator?: boolean
  indicator?: "line" | "dot" | "dashed"
  payload: {
    name: string
    value: number
    fill: string
  }[]
  nameKey?: string
  labelKey?: string
} & React.ComponentProps<"div">) {
  const tooltipLabel = hideLabel ? null : (
    <div className="font-medium">{label}</div>
  )

  if (!payload?.length) {
    return null
  }

  const nestLabel = payload.length === 1 && indicator !== "dot"

  return (
    <div
      className={cn(
        "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl transition-all ease-in-out hover:-translate-y-0.5",
        className
      )}
    >
      {!nestLabel ? tooltipLabel : null}
      <div className="grid gap-1.5">
        {payload.map((item, index) => {
          const indicatorColor = item.fill

          return (
            <div
              key={index}
              className={cn(
                "flex w-full items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
                indicator === "dot" && "items-center"
              )}
            >
              <>
                {!hideIndicator && (
                  <div
                    className={cn(
                      "shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",
                      {
                        "h-2.5 w-2.5": indicator === "dot",
                        "w-1": indicator === "line",
                        "w-0 border-[1.5px] border-dashed bg-transparent":
                          indicator === "dashed",
                        "my-0.5": nestLabel && indicator === "dashed",
                      }
                    )}
                    style={
                      {
                        "--color-bg": indicatorColor,
                        "--color-border": indicatorColor,
                      } as React.CSSProperties
                    }
                  />
                )}
                <div
                  className={cn(
                    "flex flex-1 justify-between leading-none",
                    nestLabel ? "items-end" : "items-center"
                  )}
                >
                  <div className="grid gap-1.5">
                    {nestLabel ? tooltipLabel : null}
                    <span className="text-muted-foreground">{item.name}</span>
                  </div>

Subdomains

Frequently Asked Questions

What does TooltipDemo() do?
TooltipDemo() is a function in the ui codebase, defined in deprecated/www/registry/new-york/examples/chart-tooltip-demo.tsx.
Where is TooltipDemo() defined?
TooltipDemo() is defined in deprecated/www/registry/new-york/examples/chart-tooltip-demo.tsx at line 126.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free