Gathering detailed insights and metrics for react-table-sticky
Gathering detailed insights and metrics for react-table-sticky
Gathering detailed insights and metrics for react-table-sticky
Gathering detailed insights and metrics for react-table-sticky
npm install react-table-sticky
99.1
Supply Chain
100
Quality
75.6
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
189 Stars
33 Commits
21 Forks
8 Watching
25 Branches
2 Contributors
Updated on 22 Mar 2024
Minified
Minified + Gzipped
TypeScript (86.21%)
JavaScript (12.33%)
HTML (1.46%)
Cumulative downloads
Total Downloads
Last day
-30.9%
8,415
Compared to previous day
Last week
-11.6%
55,197
Compared to previous week
Last month
-17.2%
298,326
Compared to previous month
Last year
-15.2%
3,491,975
Compared to previous year
31
Steps:
.table
.header
.body
.sticky
etc... (check following example)<div className="table sticky">
, <div className="header">
, <div className="body">
etc...useSticky
hooksticky: 'left'
or sticky: 'right'
to your columnfull example:
1import React from 'react'; 2import styled from 'styled-components'; 3import { useTable, useBlockLayout } from 'react-table'; 4import { useSticky } from 'react-table-sticky'; 5 6const Styles = styled.div` 7 .table { 8 border: 1px solid #ddd; 9 10 .tr { 11 :last-child { 12 .td { 13 border-bottom: 0; 14 } 15 } 16 } 17 18 .th, 19 .td { 20 padding: 5px; 21 border-bottom: 1px solid #ddd; 22 border-right: 1px solid #ddd; 23 background-color: #fff; 24 overflow: hidden; 25 26 :last-child { 27 border-right: 0; 28 } 29 } 30 31 &.sticky { 32 overflow: scroll; 33 .header, 34 .footer { 35 position: sticky; 36 z-index: 1; 37 width: fit-content; 38 } 39 40 .header { 41 top: 0; 42 box-shadow: 0px 3px 3px #ccc; 43 } 44 45 .footer { 46 bottom: 0; 47 box-shadow: 0px -3px 3px #ccc; 48 } 49 50 .body { 51 position: relative; 52 z-index: 0; 53 } 54 55 [data-sticky-td] { 56 position: sticky; 57 } 58 59 [data-sticky-last-left-td] { 60 box-shadow: 2px 0px 3px #ccc; 61 } 62 63 [data-sticky-first-right-td] { 64 box-shadow: -2px 0px 3px #ccc; 65 } 66 } 67 } 68`; 69 70function TableDemo() { 71 const columns = [ 72 { 73 Header: 'First Name', 74 accessor: 'firstName', 75 sticky: 'left', 76 }, 77 { 78 Header: 'Last Name', 79 accessor: 'lastName', 80 sticky: 'left', 81 }, 82 ... 83 { 84 Header: 'age', 85 accessor: 'age', 86 sticky: 'right', 87 } 88 ] 89 90 const data = [ ... ] 91 92 const { 93 getTableProps, 94 getTableBodyProps, 95 headerGroups, 96 rows, 97 prepareRow, 98 } = useTable( 99 { 100 columns, 101 data, 102 }, 103 useBlockLayout, 104 useSticky, 105 ); 106 107 // Workaround as react-table footerGroups doesn't provide the same internal data than headerGroups 108 const footerGroups = headerGroups.slice().reverse(); 109 110 return ( 111 <Styles> 112 <div {...getTableProps()} className="table sticky" style={{ width: 1000, height: 500 }}> 113 <div className="header"> 114 {headerGroups.map((headerGroup) => ( 115 <div {...headerGroup.getHeaderGroupProps()} className="tr"> 116 {headerGroup.headers.map((column) => ( 117 <div {...column.getHeaderProps()} className="th"> 118 {column.render('Header')} 119 </div> 120 ))} 121 </div> 122 ))} 123 </div> 124 <div {...getTableBodyProps()} className="body"> 125 {rows.map((row) => { 126 prepareRow(row); 127 return ( 128 <div {...row.getRowProps()} className="tr"> 129 {row.cells.map((cell) => ( 130 <div {...cell.getCellProps()} className="td"> 131 {cell.render('Cell')} 132 </div> 133 ))} 134 </div> 135 ); 136 })} 137 </div> 138 <div className="footer"> 139 {footerGroups.map((footerGroup) => ( 140 <div {...footerGroup.getHeaderGroupProps()} className="tr"> 141 {footerGroup.headers.map((column) => ( 142 <div {...column.getHeaderProps()} className="td"> 143 {column.render('Footer')} 144 </div> 145 ))} 146 </div> 147 ))} 148 </div> 149 </div> 150 </Styles> 151 ); 152} 153
Tips: if your table contain at least one header group, place yours sticky columns into a group too (even with an empty Header name)
1const columns = [ 2 { 3 Header: ' ', 4 sticky: 'left', 5 columns: [ 6 { 7 Header: 'First Name', 8 accessor: 'firstName', 9 }, 10 { 11 Header: 'Last Name', 12 accessor: 'lastName', 13 }, 14 ] 15 }, 16 { 17 Header: 'Other group', 18 columns: [ 19 ... 20 ] 21 } 22]
If you search tool for sticky position in React Table v6, take a look at react-table-hoc-fixed-columns
Check CSS sticky support https://caniuse.com/#search=sticky
git clone https://github.com/guillaumejasmin/react-table-sticky.git
npm install
npm run demo
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
102 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More