Updated
Bar List
Customize
Limit6
Number
Accent
Installation
npx shadcn@latest add https://uibrik.com/r/bar-list.jsonInstall the packages
npm install @number-flow/react @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/bar-list/bar-list.tsx"use client"; import { useMemo, useState, type CSSProperties, type ReactNode } from "react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import NumberFlow from "@number-flow/react"; import useMeasure from "react-use-measure"; import { cn } from "@/lib/utils"; import { ChartCard, DataTable, Headline, Segmented, accentVars, DRAW_IN, EASE_OUT, SETTLE, seriesColor, tint, formatShare, formatValue, type ValueFormat, } from "../_charts/chart-kit"; export type BarListItem = { label: string; value: number; href?: string };
Adds the files to
components/uibrik/bar-list and installs @number-flow/react, @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/bar-list.Too large to paste whole, so Copy prompt gives a short prompt that installs it with the CLI. Download the full prompt to attach it instead.
Usage
import { BarList } from "@/components/uibrik/bar-list/bar-list";const groups = [ { value: "pages", label: "Pages", items: [ { label: "/", value: 8420 }, { label: "/pricing", value: 3910 }, { label: "/docs/install", value: 2675 }, { label: "/blog/launch-week", value: 1840 }, { label: "/docs/theming", value: 1215 }, { label: "/changelog", value: 960 }, { label: "/components/button", value: 712 }, { label: "/about", value: 405 }, { label: "/careers", value: 268 }, ], }, { value: "referrers", label: "Referrers", items: [ { label: "Google", value: 7630 }, { label: "Direct", value: 4120 }, { label: "github.com", value: 3285 }, { label: "x.com", value: 1950 }, { label: "news.ycombinator.com", value: 1410 }, { label: "reddit.com", value: 782 }, { label: "linkedin.com", value: 516 }, { label: "DuckDuckGo", value: 304 }, ], }, // …1 more];<BarList title="Top sources" limit={6} showShare={false} accent="" groups={groups} unit="visitors" onSelect={(item) => {}} // items={[{ label: "…", value: 0 }]}/>Where to use Bar List
Top pages and referrers
Ranked rows with proportional bars make the head of a long list easy to read in analytics.
Pairs with Funnel
Leaderboards
Rows slide to their new rank when the data changes, so movement up and down the board is visible.
Pairs with Gravity Sort
Sales by product or region
Switching lists animates sizes and order instead of redrawing, which helps compare one breakdown with the next.
Pairs with Split Bar
Props
BarList- title
- Type string
- "Top sources"
- Names the list.
- limit
- Type number
- 6
- Rows shown before the rest fold into Other.
- showShare
- Type boolean
- false
- Show each row's share of the total.
- accent
- Type string
- ""
- Bar colour. Empty uses the chart palette.
- groups
- Type { value: string; label: string; items: { label: string; value: number; href?: string }[] }[]
- –
- Lists to switch between, each with its own tab.
- items
- Type { label: string; value: number; href?: string }[]
- –
- A single list. Replaces groups and hides the tabs.
- unit
- Type string
- "visitors"
- What the headline counts.
- format
- Type Intl.NumberFormatOptions
- {}
- Formats every number, e.g. { notation: "compact" }.
- onSelect
- Type (item: BarListItem) => void
- –
- Makes rows buttons and is called with the chosen item.
- className
- Type string
- –
- Classes for the outer shell.