Data Box
tdds/data-boxFreeComponent
Compact data display box with label and large value, ideal for KPIs and metrics
Install it
npx shadcn@latest add https://raw.githubusercontent.com/gjohnsx/ttb-label-verification/main/tdds-registry/public/r/data-box.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"3import { cn } from "@/lib/utils"45const dataBoxVariants = cva(6 "border border-treasury-base bg-treasury-base-lightest flex flex-col",7 {8 variants: {9 size: {10 default: "min-w-[180px]",11 sm: "min-w-[120px]",12 xs: "min-w-[90px]",13 },14 },15 defaultVariants: {16 size: "default",17 },18 }19)2021const dataBoxLabelVariants = cva(22 "font-sans text-treasury-base-dark border-b border-treasury-base-light",23 {24 variants: {25 size: {26 default: "px-4 py-3 text-base",27 sm: "px-3 py-2 text-sm",28 xs: "px-2 py-1.5 text-xs",29 },30 },31 defaultVariants: {32 size: "default",33 },34 }35)3637const dataBoxValueVariants = cva(38 "font-heading font-bold text-treasury-ink",39 {40 variants: {41 size: {42 default: "px-4 py-4 text-4xl",43 sm: "px-3 py-3 text-2xl",44 xs: "px-2 py-2 text-lg",45 },46 },47 defaultVariants: {48 size: "default",49 },50 }51)5253export interface DataBoxProps54 extends React.HTMLAttributes<HTMLDivElement>,55 VariantProps<typeof dataBoxVariants> {56 label: string57 value: string | number58}5960function DataBox({61 className,62 size,63 label,64 value,65 ...props66}: DataBoxProps) {67 return (68 <div className={cn(dataBoxVariants({ size, className }))} {...props}>69 <div className={cn(dataBoxLabelVariants({ size }))}>70 {label}71 </div>72 <div className={cn(dataBoxValueVariants({ size }))}>73 {value}74 </div>75 </div>76 )77}7879export { DataBox, dataBoxVariants }
What it pulls in
npm packages
Other registry items
Files it writes
More from tdds
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | tdds | Components | Free | 2 deps | |
| Alertalert | tdds | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | tdds | Components | Free | 1 dep | |
| Avataravatar | tdds | Components | Free | 1 dep | |
| Badgebadge | tdds | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | tdds | Components | Free | 2 deps | |
| Buttonbutton | tdds | Components | Free | 2 deps | |
| Button Groupbutton-group | tdds | Components | Free | 1 dep |
