Table
solid-ui/tableFreeComponent
A table component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/table.jsonSource
1import type { Component, ComponentProps } from "solid-js"2import { splitProps } from "solid-js"34import { cn } from "~/lib/utils"56const Table: Component<ComponentProps<"table">> = (props) => {7 const [local, others] = splitProps(props, ["class"])8 return (9 <div class="relative w-full overflow-auto">10 <table class={cn("w-full caption-bottom text-sm", local.class)} {...others} />11 </div>12 )13}1415const TableHeader: Component<ComponentProps<"thead">> = (props) => {16 const [local, others] = splitProps(props, ["class"])17 return <thead class={cn("[&_tr]:border-b", local.class)} {...others} />18}1920const TableBody: Component<ComponentProps<"tbody">> = (props) => {21 const [local, others] = splitProps(props, ["class"])22 return <tbody class={cn("[&_tr:last-child]:border-0", local.class)} {...others} />23}2425const TableFooter: Component<ComponentProps<"tfoot">> = (props) => {26 const [local, others] = splitProps(props, ["class"])27 return (28 <tfoot class={cn("bg-primary font-medium text-primary-foreground", local.class)} {...others} />29 )30}3132const TableRow: Component<ComponentProps<"tr">> = (props) => {33 const [local, others] = splitProps(props, ["class"])34 return (35 <tr36 class={cn(37 "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",38 local.class39 )}40 {...others}41 />42 )43}4445const TableHead: Component<ComponentProps<"th">> = (props) => {46 const [local, others] = splitProps(props, ["class"])47 return (48 <th49 class={cn(50 "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",51 local.class52 )}53 {...others}54 />55 )56}5758const TableCell: Component<ComponentProps<"td">> = (props) => {59 const [local, others] = splitProps(props, ["class"])60 return (61 <td class={cn("p-2 align-middle [&:has([role=checkbox])]:pr-0", local.class)} {...others} />62 )63}6465const TableCaption: Component<ComponentProps<"caption">> = (props) => {66 const [local, others] = splitProps(props, ["class"])67 return <caption class={cn("mt-4 text-sm text-muted-foreground", local.class)} {...others} />68}6970export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption }
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
