Table

A Table component is a structured UI element that organizes and displays data in rows and columns, making it easy to read and compare information. Tables can include features like sorting, filtering, pagination, and inline editing, allowing users to interact with the data efficiently. They are commonly used to present datasets, such as user information, product listings, or any structured content that benefits from a grid-like layout.
# Demo
Invoice table
InvoiceStatusMethodAmountCustom
10001CompletedCredit Card$1000
Oops
10002In progressNet Banking$500
Oops
# Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
captionClassNamestring' 'You can customise by passing tailwind classes.
headerClassNamestring' 'You can customise by passing tailwind classes.
headerRowClassNamestring' 'You can customise by passing tailwind classes.
headerCellClassNamestring' 'You can customise by passing tailwind classes.
bodyClassNamestring' 'You can customise by passing tailwind classes.
bodyRowClassNamestring' 'You can customise by passing tailwind classes.
bodyCellClassNamestring' 'You can customise by passing tailwind classes.
captionstring' 'You can pass caption to table.
columnDefColumnDef[]RequiredYou can pass column definition to table.
dataObject[]RequiredYou can pass data to table.
# Usage
import { NTable } from 'nayan'; const CustomComponent = ({row, col, ...remaining}: any) => { return <div className="text-primary">Oops</div>; }; const Table = () => { const columnDef = [ { name: 'invoice', title: 'Invoice', className: 'w-[100px]' }, { name: 'status', title: 'Status' }, { name: 'method', title: 'Method' }, { name: 'amount', title: 'Amount', className: 'text-right' }, { name: 'custom', title: 'Custom', className: 'text-right', component: CustomComponent } ]; const data = [ { invoice: '10001', status: 'Completed', method: 'Credit Card', amount: '$1000' }, { invoice: '10002', status: 'In progress', method: 'Net Banking', amount: '$500' } ]; return <NTable className="bg-card" caption="Invoice table" columnDef={columnDef} data={data} />; }; export default Table;