Table

alpha
Efficiently organize and present tabular data with a customizable, flexible display method.
Installation
API Reference
This is an illustration of a Table component.
<Table className="w-full">
<TableHeader>
<TableRow>
<TableHead>Customer Name</TableHead>
<TableHead>Units</TableHead>
<TableHead>Costs</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableData>Rajesh Kumar</TableData>
<TableData>10</TableData>
<TableData>$130</TableData>
</TableRow>
<TableRow>
<TableData>Priya Sharma</TableData>
<TableData>12</TableData>
<TableData>$210</TableData>
</TableRow>
<TableRow>
<TableData>Ravi Patel</TableData>
<TableData>6</TableData>
<TableData>$55</TableData>
</TableRow>
<TableRow>
<TableData>Ananya Gupta</TableData>
<TableData>18</TableData>
<TableData>$340</TableData>
</TableRow>
<TableRow>
<TableData>Arjun Singh</TableData>
<TableData>2</TableData>
<TableData>$35</TableData>
</TableRow>
</TableBody>
<TableFooter>
<TableRow>
<TableHead>Total</TableHead>
<TableHead>48</TableHead>
<TableHead>$770</TableHead>
</TableRow>
</TableFooter>
</Table>

Installation

Run the following command:

npx gluestack-ui add table

API Reference

To use this component in your project, include the following import statement in your file.
import {
Table,
TableHeader,
TableFooter,
TableBody,
TableHead,
TableData,
TableRow,
TableCaption,
} from "@/components/ui/table"
anatomy-image
export default () => (
<Table>
<TableHeader>
<TableRow>
<TableHead />
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableData />
</TableRow>
</TableBody>
<TableFooter>
<TableRow>
<TableData />
</TableRow>
</TableFooter>
<TableCaption />
</Table>
)

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Table

It inherits all the properties of of @expo/html-elements's Table on native and html table tag on web.

TableHeader

It inherits all the properties of of @expo/html-elements's THead on native and html thead tag on web.

TableRow

It inherits all the properties of of @expo/html-elements's TR on native and html tr tag on web.

TableData

It inherits all the properties of React Native's Text component on native and html td tag on web.
Prop
Type
Default
useRNView
boolean
If true renders a react-native view component instead of a text component.

TableHead

It inherits all the properties of React Native's Text component on native and html th tag on web.
Prop
Type
Default
useRNView
boolean
If true renders a react-native view component instead of a text component.

TableBody

It inherits all the properties of of @expo/html-elements's TBody on native and html tbody tag on web.

TableFooter

It inherits all the properties of of @expo/html-elements's TFoot on native and html tfoot tag on web.

TableCaption

It inherits all the properties of of @expo/html-elements's Caption on native and html caption tag on web.

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Table with caption

This is an example of a Table component with a caption.
function App() {
return (
<Box className="rounded-lg overflow-hidden w-full">
<Table className="w-full">
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Email Address</TableHead>
<TableHead>Phone Number</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableData>Rajesh Kumar</TableData>
<TableData fontWeight="$normal">rajesh@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
<TableRow>
<TableData>Priya Sharma</TableData>
<TableData fontWeight="$normal">priya@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
<TableRow>
<TableData>Ravi Patel</TableData>
<TableData fontWeight="$normal">ravi@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
<TableRow>
<TableData>Ananya Gupta</TableData>
<TableData fontWeight="$normal">ananya@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
<TableRow>
<TableData>Arjun Singh</TableData>
<TableData fontWeight="$normal">arjun@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
<TableRow>
<TableData>Nisha Verma</TableData>
<TableData fontWeight="$normal">nisha@example.com</TableData>
<TableData fontWeight="$normal">1234567890</TableData>
</TableRow>
</TableBody>
<TableCaption fontWeight="$normal">
Showing recent membership details
</TableCaption>
</Table>
</Box>
)
}

Stripped table

This example demonstrates a table with a striped background.
function App() {
return (
<Box className="p-3 bg-background-0 rounded-lg overflow-hidden">
<Table className="w-full">
<TableHeader>
<TableRow className="border-b-0 bg-background-0 hover:bg-background-0">
<TableHead className="font-bold">Order id</TableHead>
<TableHead>Items</TableHead>
<TableHead>Name</TableHead>
<TableHead>City</TableHead>
<TableHead>Order price</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow className="border-b-0 bg-background-50">
<TableData>5771</TableData>
<TableData>3</TableData>
<TableData>Rajesh Kumar</TableData>
<TableData>New Jersey</TableData>
<TableData>$ 200</TableData>
<TableData>
<Badge
size="sm"
action="success"
className="w-fit justify-center"
>
<BadgeText>Completed</BadgeText>
</Badge>
</TableData>
</TableRow>
<TableRow className="border-b-0 hover:bg-background-0">
<TableData>5231</TableData>
<TableData>2</TableData>
<TableData>Priya Sharma</TableData>
<TableData>Austin</TableData>
<TableData>$ 150</TableData>
<TableData>
<Badge size="sm" action="info" className="w-fit justify-center">
<BadgeText>Processing</BadgeText>
</Badge>
</TableData>
</TableRow>
<TableRow className="border-b-0 bg-background-50">
<TableData>5771</TableData>
<TableData>3</TableData>
<TableData>Ravi Patel</TableData>
<TableData>Seattle</TableData>
<TableData>$ 215</TableData>
<TableData>
<Badge
size="sm"
action="warning"
className="w-fit justify-center"
>
<BadgeText>Shipped</BadgeText>
</Badge>
</TableData>
</TableRow>
<TableRow className="border-b-0 hover:bg-background-0">
<TableData>5231</TableData>
<TableData>4</TableData>
<TableData>Ananya Gupta</TableData>
<TableData>California</TableData>
<TableData>$ 88</TableData>
<TableData>
<Badge size="sm" action="info" className="w-fit justify-center">
<BadgeText>Processing</BadgeText>
</Badge>
</TableData>
</TableRow>
<TableRow className="border-b-0 bg-background-50">
<TableData>5771</TableData>
<TableData>3</TableData>
<TableData>Arjun Singh</TableData>
<TableData>Seattle</TableData>
<TableData>$ 115</TableData>
<TableData>
<Badge
size="sm"
action="success"