A lightweight, powerful, and fully headless data table library for React
npm install @morne004/headless-react-data-tablebash
npm install @morne004/headless-react-data-table
`
Or using yarn/pnpm:
`bash
yarn add @morne004/headless-react-data-table
pnpm add @morne004/headless-react-data-table
`
Peer Dependencies:
- React 18.0.0+ or React 19.0.0+
- React-DOM 18.0.0+ or React 19.0.0+
---
Quick Start
`tsx
import { DataTable } from '@morne004/headless-react-data-table';
import type { ColumnDef } from '@morne004/headless-react-data-table';
interface User {
id: number;
name: string;
email: string;
status: 'active' | 'inactive';
}
const data: User[] = [
{ id: 1, name: 'John Doe', email: 'john@example.com', status: 'active' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'inactive' },
];
const columns: ColumnDef[] = [
{
id: 'name',
accessorKey: 'name',
header: 'Name',
},
{
id: 'email',
accessorKey: 'email',
header: 'Email',
},
{
id: 'status',
accessorKey: 'status',
header: 'Status',
cell: ({ row }) => (
{row.status}
),
},
];
function App() {
return (
Users
);
}
`
That's it! The table now has:
- ā
Sorting (click headers)
- ā
Search (global filter)
- ā
Pagination
- ā
Column visibility toggle
- ā
Persistent state in localStorage
Style it your way:
`tsx
// Add Tailwind CSS classes
// Or use custom components
data={data}
columns={columns}
components={{
Toolbar: MyCustomToolbar,
Pagination: MyCustomPagination,
}}
/>
`
š See more examples in EXAMPLES.md
---
Key Features
$3
- Sorting - Click headers to sort ascending/descending/unsorted ⢠Learn more ā
- Filtering - Global search + advanced multi-column filters with 6 operators ⢠Learn more ā
- Pagination - Client-side pagination with customizable page sizes ⢠Learn more ā
- Search - Instant search across all columns ⢠Learn more ā
$3
- Column Visibility - Show/hide columns with persistence ⢠Learn more ā
- Column Reordering - Drag-and-drop to reorder ⢠Learn more ā
- Column Resizing - Manual width adjustment ⢠Learn more ā
- Condensed View - Toggle between normal and compact density ⢠Learn more ā
$3
- TypeScript - Full type safety with generics ⢠Learn more ā
- Headless Architecture - Complete UI customization ⢠Learn more ā
- State Management - Controlled and uncontrolled modes ⢠Learn more ā
- CSV Export - Built-in export utility ⢠Learn more ā
- Custom Cell Renderers - Render any React component ⢠Learn more ā
- Component Slots - Replace toolbar, pagination, filters, skeleton ⢠Learn more ā
š View all features with examples ā
---
What's Next?
$3
Explore all capabilities with detailed explanations:
š FEATURES.md - Complete feature catalog
- Core features (sorting, filtering, pagination)
- UI features (column controls, condensed view)
- State management (persistence, controlled mode)
- Customization options
$3
Copy-paste ready code for common use cases:
š” EXAMPLES.md - Real-world patterns
- Basic examples (minimal setup, TypeScript)
- Styled examples (Tailwind, Material-UI)
- Server-side integration (REST API, React Query)
- Framework examples (Next.js, Remix)
- Advanced patterns (editable cells, row selection, master-detail)
- Custom cell renderers (currency, dates, badges, actions)
$3
Complete reference for all props, hooks, and types:
š USAGE.md - API reference and integration guide
- Installation and setup
- Complete API reference
- TypeScript usage
- State management guide
- Performance tips
- Troubleshooting
- Migration guides
---
Real-World Examples
$3
`tsx
const [tableState, setTableState] = useState({
pageIndex: 0,
pageSize: 25,
globalFilter: '',
});
const [users, setUsers] = useState([]);
const [totalCount, setTotalCount] = useState(0);
useEffect(() => {
fetch(/api/users?page=${tableState.pageIndex}&pageSize=${tableState.pageSize}&search=${tableState.globalFilter})
.then(res => res.json())
.then(response => {
setUsers(response.data); // Current page data (e.g., 25 items)
setTotalCount(response.total); // Total count from server (e.g., 1000)
});
}, [tableState]);
data={users}
columns={columns}
state={tableState}
onStateChange={setTableState}
manualPagination={true}
totalRowCount={totalCount}
pageCount={Math.ceil(totalCount / tableState.pageSize)}
/>
`
Important: When using server-side pagination, you must:
- Set manualPagination={true} to disable client-side pagination
- Provide totalRowCount (total items on server)
- Provide pageCount (total pages = Math.ceil(totalCount / pageSize))
- The data prop should contain only the current page's items
$3
`tsx
const { data, isLoading } = useQuery(['users'], fetchUsers);
data={data || []}
columns={columns}
isLoading={isLoading}
/>
`
$3
`tsx
const columns: ColumnDef[] = [
{
id: 'price',
accessorKey: 'price',
header: 'Price',
cell: ({ row }) => new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(row.price),
},
];
`
š See 20+ complete examples ā
---
Community & Support
$3
- š¬ GitHub Discussions - Ask questions, share ideas
- š GitHub Issues - Report bugs, request features
- š Documentation - Complete feature guide
$3
- š¦ npm Package - Latest version
- š GitHub Repository - Source code, releases
- š Changelog - What's new
---
Contributing
Contributions are welcome! Here's how you can help:
$3
Found a bug or have a feature request?
1. Check existing issues
2. Create a new issue with:
- Clear description
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Code example if possible
$3
`bash
Clone the repository
git clone https://github.com/Morne004/advnaced-react-table.git
cd advnaced-react-table
Install dependencies
npm install
Start development server
npm run dev
Build for production
npm run build
Run tests (if available)
npm test
`
$3
`
src/
āāā lib/ # Library source code
ā āāā components/ # React components (DataTable, etc.)
ā āāā hooks/ # Custom hooks (useDataTable, etc.)
ā āāā types.ts # TypeScript type definitions
ā āāā utils/ # Utility functions (CSV export, etc.)
ā āāā index.ts # Main entry point
āāā demo/ # Demo application
āāā App.tsx # Demo examples
`
$3
- Write clear, descriptive commit messages
- Follow existing code style
- Add TypeScript types for new features
- Update documentation for API changes
- Test your changes locally before submitting
- Be respectful and constructive in discussions
$3
1. Fork the repository
2. Create a feature branch (git checkout -b feature/amazing-feature)
3. Make your changes
4. Commit your changes (git commit -m 'Add amazing feature')
5. Push to your branch (git push origin feature/amazing-feature)
6. Open a Pull Request
---
Changelog
See GitHub Releases for version history and release notes.
$3
- v1.0.4 - Added condensed view as first-class feature
- v1.0.3 - Fixed column resize stuck bug (stale closure issue)
- v1.0.2 - Fixed controlled mode state loss bug
- v1.0.1 - Added missing exportToCsv` export, removed demo types