Bulk Select
Bulk select allows users to check multiple checkboxes at once and toggles a UI for bulk actions to be performed for the selected items.
Bulk select consist of this following parts
- The main checkbox, which is used for checking all the other checkboxes, the attribute
data-bulk-select
is used to define that item. - Three(3) elements can be hooked with bulk select:
body
,actions
,replacedElement
.<input class="form-check-input" type="checkbox" data-bulk-select='{"body":"bulk-select-body","actions":"bulk-select-actions","replacedElement":"bulk-select-replace-element"}' />
These ids definded in these keys are used to hook the respective elements.
body:
The target checkboxes are wrapped using a unique id defined inbody
. In this examplebulk-select-body
. Every targeted checkbox within this wrapper is marked with the attributedata-bulk-select-row.
actions:
The target actions are wrapped using a unique id defined inactions
. The element with this id (inexample bulk-select-actions
) will be toggled by checking the main checkbox.replacedElement:
The target replaced element with action are wrapped using a unique id defined inreplacedElement
. Bulk select actions will be replaced with the content of this element with this id (in examplebulk-select-replace-element
)
Example
<div class="card mx-ncard my-ncard shadow-none">
<div class="card-body">
<div class="table-responsive scrollbar">
<table class="table mb-0">
<thead class="text-black bg-200">
<tr>
<th class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" data-bulk-select='{"body":"bulk-select-body","actions":"bulk-select-actions","replacedElement":"bulk-select-replace-element"}' />
</div>
</th>
<th class="align-middle">Name</th>
<th class="align-middle">Nationality </th>
<th class="align-middle">Gender</th>
<th class="align-middle white-space-nowrap pe-3">Age</th>
</tr>
</thead>
<tbody id="bulk-select-body">
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-1" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Kit Harington</th>
<td class="align-middle">British</td>
<td class="align-middle">Male</td>
<td class="align-middle white-space-nowrap text-end pe-3">32</td>
</tr>
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-2" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Emilia Clarke</th>
<td class="align-middle">British</td>
<td class="align-middle">Female</td>
<td class="align-middle white-space-nowrap text-end pe-3">32</td>
</tr>
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-3" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Peter Dinklage</th>
<td class="align-middle">American</td>
<td class="align-middle">Male</td>
<td class="align-middle white-space-nowrap text-end pe-3">49</td>
</tr>
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-4" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Sean Bean</th>
<td class="align-middle">British</td>
<td class="align-middle">Male</td>
<td class="align-middle white-space-nowrap text-end pe-3">59</td>
</tr>
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-5" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Maisie Williams</th>
<td class="align-middle">British</td>
<td class="align-middle">Female</td>
<td class="align-middle white-space-nowrap text-end pe-3">21</td>
</tr>
<tr>
<td class="align-middle white-space-nowrap">
<div class="form-check mb-0">
<input class="form-check-input" type="checkbox" id="checkbox-6" data-bulk-select-row="data-bulk-select-row" />
</div>
</td>
<th class="align-middle">Sophie Turner</th>
<td class="align-middle">British</td>
<td class="align-middle">Female</td>
<td class="align-middle white-space-nowrap text-end pe-3">23</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>