JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
<script src="https://cdn.datatables.net/select/1.2.7/js/dataTables.select.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.7/css/select.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/fixedcolumns/3.2.5/css/fixedColumns.bootstrap4.min.css">
<script src="https://cdn.datatables.net/fixedcolumns/3.2.5/js/dataTables.fixedColumns.min.js"></script>
<div>
<table id="example" class="table display" style="width:100%">
<thead>
<tr>
<th>
<input name="selectAll" type="checkbox" id="selectAll1" class="select-all">
<label for="selectAll1"></label>
</th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
<tr>
<td></td>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>$170,750</td>
</tr>
<tr>
<td></td>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>$86,000</td>
</tr>
<tr>
<td></td>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>$433,060</td>
</tr>
</tbody>
</table>
</div>
<div>
<table id="example2" class="table display" style="width:100%">
<thead>
<tr>
<th>
<input name="selectAll"...
SCSS
body {
padding: 20px;
> div {
border: 5px solid #000;
padding: 10px;
& + div {
margin-top: 10px;
}
}
}
thead tr th {
position: relative;
input[type=checkbox] {
position: absolute;
top: auto;
overflow: hidden;
clip: rect(1px 1px 1px 1px);
/* IE 6/7 */
clip: rect(1px, 1px, 1px, 1px);
width: 1px;
height: 1px;
white-space: nowrap;
}
input[type=checkbox]+label::before {
content: '';
display: inline-block;
margin-top: 1px;
width: 14px;
height: 14px;
border: 1px solid #000;
border-radius: 3px;
background-color: #FFF;
}
input[type=checkbox]:checked+label::before {
content: '\2714';
text-shadow: 1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9;
}
}
JavaScript
$(document).ready(function() {
$('#example').DataTable({
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'multi+shift',
selector: 'td:first-child'
},
order: [
[1, 'asc']
]
});
$('#example2').DataTable({
"scrollX": true,
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
fixedColumns: {
leftColumns: 1,
rightColumns: 1
},
select: {
style: 'multi+shift',
selector: 'td:first-child'
},
order: [
[1, 'asc']
]
});
});