Componentdata
Rank List
Ranked list with drag-to-reorder and score readouts.
Preview
Live Preview
- 01First Place900
- 02Second Place750
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add rank-listOr install the full npm package:
npm install bigbulluiUsage
import { RankList } from "@/components/ui/rank-list";
<RankList />Source code
rank-list.tsxZero dependencies (only React + utils). Copy and paste directly into your project:
"use client";
import * as React from "react";
import { cn } from "./lib/utils";
import { DragSort, type DragSortItem } from "./drag-sort";
export interface RankListProps extends React.HTMLAttributes<HTMLDivElement> {
items: { id: string; label: string; score?: number }[];
onReorder?: (items: DragSortItem[]) => void;
}
/** Sıralı liste: sürükle-bırak sıralama + skor. */
export function RankList({ items, onReorder, className, ...props }: RankListProps) {
const dragItems: DragSortItem[] = items.map((it) => ({
id: it.id,
content: (
<span className="flex items-center justify-between gap-3">
<span className="truncate">{it.label}</span>
{it.score !== undefined && (
<span className="shrink-0 font-mono text-xs tabular-nums text-accent">{it.score.toLocaleString("tr-TR")}</span>
)}
</span>
),
}));
return (
<div className={cn("w-full max-w-md", className)} {...props}>
<DragSort items={dragItems} onReorder={onReorder} />
</div>
);
}
Props
| Prop | Type | Description |
|---|---|---|
| items | { id: string; label: string; score?: number }[] | |
| onReorder | (items: DragSortItem[]) => void |