
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
react-inclusive-sortable-table
Advanced tools
An accessible, sortable table based off of Heydon Pickering's Sortable Table from Inclusive Components.
An accessible, responsive, sortable table based off of Heydon Pickering's Sortable Table from Inclusive Components.
Read the artice! Data Tables
This component displays a <table>
on large viewports and a definition list <dl>
on small viewports.
Demo: https://benjamingrobertson.github.io/react-inclusive-sortable-table/
npm install --save react-inclusive-sortable-table
import React, { Component } from 'react'
import Table from 'react-inclusive-sortable-table'
class Example extends Component {
render () {
const headers = ['Site', 'Founder', 'Inception', 'URL'];
const rows = [
[
'CSS Tricks',
'Chris Coyier',
'2007',
<a href="http://css-tricks.com">http://css-tricks.com</a>
],
[
'Smashing Magazine',
'Vitaly Friedman and Sven Lennartz',
'2006',
<a href="https://www.smashingmagazine.com/">
https://www.smashingmagazine.com/
</a>
],
[
'A List Apart',
'Jeffrey Zeldman',
'1998',
<a href="https://alistapart.com/">https://alistapart.com/</a>
],
[
'codrops',
'Manoela Ilic and Pedro Botelho',
'2009',
<a href="https://tympanus.net/codrops/">
https://tympanus.net/codrops/
</a>
]
];
return (
<Table
rows={rows}
headers={headers}
rowHeaders
caption="Front end websites"
sortable
/>
)
}
}
An optional value, in pixels, of where you want the definition list to change to a table. The default is 400px. If you use the default setting, the breakpoints are managed in CSS.
If you pass in a value, the component will add a debounced window resize listener for triggering the render.
<Table
breakpoint={500}
rows={rows}
headers={headers}
rowHeaders
caption="Front end websites"
sortable
/>
The title of your table. Will be wrapped in a <caption>
for the table display and an <h2>
for the definition list display.
An optional class name to use for custom styling. Will be added to the component wrapper.
A render props method for using a custom arrow icon.
Here is an example of how you override the arrow with a custom component:
<Table
customArrow={(sortDir, isCurrent) => (
<p>
{sortDir}, {isCurrent}
</p>
)}
caption="Front end websites"
headers={headers}
rows={rows}
sortable
/>
The default arrow looks like this (it uses sortDirection and isCurrent to determine which way the arrow should point):
let ascending = sortDir === 'ascending'
return (
<svg viewBox='0 0 100 200' width='100' height='200'>
{!(!ascending && isCurrent) && (
<polyline points='20 50, 50 20, 80 50' />
)}
<line x1='50' y1='20' x2='50' y2='180' />
{!(ascending && isCurrent) && (
<polyline points='20 150, 50 180, 80 150' />
)}
</svg>
)
This should take an object, with the keys of the object reflecting the index of the array you want to sort, and the value reflecting the method you want to pass to Array.sort()
.
Usage:
<Table
customSort={{
// This will pass a custom sort method to the 2nd column.
1: (a, b, sortDirection, index) => {
// do your sorting here
}
}}
/>
An array of table headers. Will be wrapped in <th>
for the table display and <dt>
for the definition list display.
A boolean, determines whether or not to wrap the first column in each row in a <th>
for the table display.
It makes the font-weight bold.
An array of arrays for each row, containing the data for the table.
For example:
[
[
'CSS Tricks',
'Chris Coyier',
'2007',
<a href="http://css-tricks.com">http://css-tricks.com</a>
],
[
'Smashing Magazine',
'Vitaly Friedman and Sven Lennartz',
'2006',
<a href="https://www.smashingmagazine.com/">
https://www.smashingmagazine.com/
</a>
],
[
'A List Apart',
'Jeffrey Zeldman',
'1998',
<a href="https://alistapart.com/">https://alistapart.com/</a>
],
[
'codrops',
'Manoela Ilic and Pedro Botelho',
'2009',
<a href="https://tympanus.net/codrops/">
https://tympanus.net/codrops/
</a>
]
];
Can be either a boolean or an array. By default, no columns will be sortable.
If it is passed without arguments (ie, <Table sortable />
), all columns will be sortable.
To control what columns to sort, pass in an array containing the index of the columns you want to sort.
For example, to sort the 2nd and 4th columns:
<Table
caption="Front end websites"
headers={headers}
rows={rows}
sortable={[1, 3]}
/>
MIT © benjamingrobertson
FAQs
An accessible, sortable table based off of Heydon Pickering's Sortable Table from Inclusive Components.
The npm package react-inclusive-sortable-table receives a total of 24 weekly downloads. As such, react-inclusive-sortable-table popularity was classified as not popular.
We found that react-inclusive-sortable-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.