Position Table
solanaui/position-tableFreeComponent
A sortable table of open trading positions with built-in TP/SL editor and close position dialogs.
Live preview
live · rendered by the registry
Rendered by solanaui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solanaui.dev/r/position-table.jsonSource
1"use client";23import {4 ChevronDownIcon,5 ChevronUpIcon,6 PencilIcon,7 XIcon,8} from "lucide-react";9import React from "react";10import { ActionBox } from "@/registry/sol/action-box";11import { OrderForm } from "@/registry/sol/order-form";12import { TokenIcon } from "@/registry/sol/token-icon";13import { Button } from "@/components/ui/button";14import {15 Dialog,16 DialogContent,17 DialogDescription,18 DialogTitle,19 DialogTrigger,20} from "@/components/ui/dialog";21import {22 Table,23 TableBody,24 TableCell,25 TableHead,26 TableHeader,27 TableRow,28} from "@/components/ui/table";29import type { SortDirection } from "@/registry/lib/sort-utils";30import { compareValues } from "@/registry/lib/sort-utils";31import { cn } from "@/lib/utils";3233interface PositionTablePosition {34 symbol: string;35 icon: string;36 side: "long" | "short";37 size: string;38 value: string;39 leverage: string;40 entryPrice: string;41 markPrice: string;42 liquidationPrice?: string;43 pnl: string;44 pnlPercent?: string;45 pnlTrend?: "up" | "down";46}4748interface PositionTableProps {49 positions: PositionTablePosition[];50 onEditTpSl?: (51 position: PositionTablePosition,52 values: {53 tpPrice: string;54 tpPercent: string;55 slPrice: string;56 slPercent: string;57 },58 ) => void;59 onClosePosition?: (position: PositionTablePosition) => void;60 className?: string;61}6263const SORT_KEYS = [64 "side",65 "symbol",66 "size",67 "value",68 "entryPrice",69 "markPrice",70 "leverage",71 "pnl",72] as const;7374type SortKey = (typeof SORT_KEYS)[number];7576const SortableHeader = ({77 label,78 sortKey,79 activeSortKey,80 sortDirection,81 onSort,82 className,83}: {84 label: string;85 sortKey: SortKey;86 activeSortKey: SortKey | null;87 sortDirection: SortDirection;88 onSort: (key: SortKey) => void;89 className?: string;90}) => {91 const isActive = activeSortKey === sortKey;92 return (93 <TableHead className={className}>94 <button95 type="button"96 onClick={() => onSort(sortKey)}97 className={cn(98 "inline-flex items-center gap-1 cursor-pointer hover:text-foreground transition-colors",99 isActive ? "text-foreground" : "text-muted-foreground",100 )}101 >102 {label}103 {isActive && sortDirection === "asc" && (104 <ChevronUpIcon className="size-3.5" />105 )}106 {isActive && sortDirection === "desc" && (107 <ChevronDownIcon className="size-3.5" />108 )}109 </button>110 </TableHead>111 );112};113114// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from solanaui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Boxaction-box | solanaui | Components | Free | no deps | |
| Activity Feedactivity-feed | solanaui | Components | Free | 1 dep | |
| Address Displayaddress-display | solanaui | Components | Free | 1 dep | |
| Auth Cardauth-card | solanaui | Components | Free | no deps | |
| Health Barhealth-bar | solanaui | Components | Free | no deps | |
| Leverage Sliderleverage-slider | solanaui | Components | Free | no deps | |
| NFT Cardnft-card | solanaui | Components | Free | no deps | |
| Order Bookorder-book | solanaui | Components | Free | no deps |
