Table

Tableau de donnees stylise avec des sections d'en-tete, de corps et de pied de page. Installez Table depuis le registre VLLNT UI avec la CLI shadcn.

Signaler un bug

Tableau de donnees stylise avec des sections d'en-tete, de corps et de pied de page. Fait partie de la famille data dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Installation

Ajoutez Table a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/table.json

Source

import { cn } from "../../lib/utils"; const Table = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableElement> & { ref?: React.Ref<HTMLTableElement>; }) => ( <div className="relative w-full overflow-auto"> <table className={cn("w-full caption-bottom text-sm", className)} ref={ref} {...props} /> </div> ); Table.displayName = "Table"; const TableHeader = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement>; }) => ( <thead className={cn("[&_tr]:border-b", className)} ref={ref} {...props} /> ); TableHeader.displayName = "TableHeader"; const TableBody = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement>; }) => ( <tbody className={cn("[&_tr:last-child]:border-0", className)} ref={ref} {...props} /> ); TableBody.displayName = "TableBody"; const TableFooter = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement>; }) => ( <tfoot className={cn( "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className, )} ref={ref} {...props} /> ); TableFooter.displayName = "TableFooter"; const TableRow = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableRowElement> & { ref?: React.Ref<HTMLTableRowElement>; }) => ( <tr className={cn( "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", className, )} ref={ref} {...props} /> ); TableRow.displayName = "TableRow"; const TableHead = ({ className, ref, ...props }: React.ThHTMLAttributes<HTMLTableCellElement> & { ref?: React.Ref<HTMLTableCellElement>; }) => ( <th className={cn( "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", className, )} ref={ref} {...props} /> ); TableHead.displayName = "TableHead"; const TableCell = ({ className, ref, ...props }: React.TdHTMLAttributes<HTMLTableCellElement> & { ref?: React.Ref<HTMLTableCellElement>; }) => ( <td className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} ref={ref} {...props} /> ); TableCell.displayName = "TableCell"; const TableCaption = ({ className, ref, ...props }: React.HTMLAttributes<HTMLTableCaptionElement> & { ref?: React.Ref<HTMLTableCaptionElement>; }) => ( <caption className={cn("mt-4 text-sm text-muted-foreground", className)} ref={ref} {...props} /> ); TableCaption.displayName = "TableCaption"; export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, };

Stories

Explorez chaque variante et etat dans le Storybook interactif :

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Dependances

  • @vllnt/ui@^0.3.0