LYX UI

Tracker

A flexible uptime/status tracker component with hoverable tooltips, ideal for status pages and dashboards.

Example

example.com

99.9%

uptime

90 days agoToday
Operational
Performance Issues
Service Unavailable
No Data

Installation

npx shadcn@latest add http://lyxui.wisplabs.xyz/r/tracker.json

Manual

Install the following dependencies:

bash npm install @radix-ui/react-hover-card

Copy the source code to components/lyxui/tracker.tsx

"use client";
 import React from "react";
 import * as HoverCardPrimitives from "@radix-ui/react-hover-card";
 
 import { cn } from "@/lib/utils";
 
 interface TrackerBlockProps {
   key?: string | number;
   color?: string;
   tooltip?: string;
   hoverEffect?: boolean;
   defaultBackgroundColor?: string;
 }
 
 const Block = ({
   color,
   tooltip,
   defaultBackgroundColor,
   hoverEffect,
 }: TrackerBlockProps) => {
   const [open, setOpen] = React.useState(false);
   return (
     <HoverCardPrimitives.Root
       open={open}
       onOpenChange={setOpen}
       openDelay={0}
       closeDelay={0}
       tremor-id="tremor-raw"
     >
       <HoverCardPrimitives.Trigger onClick={() => setOpen(true)} asChild>
         <div className="size-full overflow-hidden px-[0.5px] transition first:rounded-l-[4px] first:pl-0 last:rounded-r-[4px] last:pr-0 sm:px-px">
           <div
             className={cn(
               "size-full rounded-[1px]",
               color || defaultBackgroundColor,
               hoverEffect ? "hover:opacity-50" : ""
             )}
           />
         </div>
       </HoverCardPrimitives.Trigger>
       <HoverCardPrimitives.Portal>
         <HoverCardPrimitives.Content
           sideOffset={10}
           side="top"
           align="center"
           avoidCollisions
           className={cn(
             // base
             "w-auto rounded-md px-2 py-1 text-sm shadow-md",
             // text color
             "text-white dark:text-gray-900",
             // background color
             "bg-gray-900 dark:bg-gray-50"
           )}
         >
           {tooltip}
         </HoverCardPrimitives.Content>
       </HoverCardPrimitives.Portal>
     </HoverCardPrimitives.Root>
   );
 };
 
 Block.displayName = "Block";
 
 interface TrackerProps extends React.HTMLAttributes<HTMLDivElement> {
   data: TrackerBlockProps[];
   defaultBackgroundColor?: string;
   hoverEffect?: boolean;
 }
 
 const Tracker = React.forwardRef<HTMLDivElement, TrackerProps>(
   (
     {
       data = [],
       defaultBackgroundColor = "bg-gray-400 dark:bg-gray-400",
       className,
       hoverEffect,
       ...props
     },
     forwardedRef
   ) => {
     return (
       <div
         ref={forwardedRef}
         className={cn("group flex h-8 w-full items-center", className)}
         {...props}
       >
         {data.map((props, index) => (
           <Block
             key={props.key ?? index}
             defaultBackgroundColor={defaultBackgroundColor}
             hoverEffect={hoverEffect}
             {...props}
           />
         ))}
       </div>
     );
   }
 );
 
 Tracker.displayName = "Tracker";
 
 export { Tracker, type TrackerBlockProps };

You are ready to use the component! Simply import it and start using it in your code.

Props

PropTypeDefault
className?
string
""
hoverEffect?
boolean
false
defaultBackgroundColor?
string
"bg-gray-400 dark:bg-gray-400"
data?
TrackerBlockProps[]
required

TrackerBlockProps

PropTypeDefault
defaultBackgroundColor?
string
"bg-gray-400 dark:bg-gray-400"
hoverEffect?
boolean
false
tooltip?
string
""
color?
string
"bg-gray-400 dark:bg-gray-400"
key?
string | number
index

For more advanced usage, see the source code or customize the block rendering.

On this page