This library is still in development and is available only for internal usage at VTEX.
Skip to main content

Bulk Actions

Version: 0.134.0

Bulk Actions

What is this?

Bulk actions allows the user to perform actions in one or more selected items.

Usage

import { useBulkActions, BulkActions } from '@vtex/admin-ui'

function Example() {
const state = useBulkActions({ pageItems, totalItems })

return (
<BulkActions state={state}>
<Button>Action 1</Button>
<Button>Action 2</Button>
</BulkActions>
)
}

Examples

Without pagination

Loading...

With Pagination

Loading...

Props

UseBulkActionsParams

The props you can pass as a parameter to the useBulkActions hook.

NameTypeDescriptionRequiredDefault
pageItemsT[] where T extends { id: string,number }Items of the Page-
totalItemsnumberThe total number of items-
pageSizenumberThe number of items per page-

BulkActionState

The props returned by the useBulkActions hook.

NameTypeDescriptionDefault
totalItemsnumberThe total number of items-
pageIdsArray<string,number>IDs from the page items-
getSelectedIds() => Array<string,number>Returns the IDs from the selected items-
pageSelectedItemsT[]Return the selected items from the current page-
isItemSelected(item: T) => booleanReturns whether the item is selected or not-
isVisiblebooleanWhether the BulkAction component is visible or not-
allSelectedbooleanWhether all the items are selected or not-
setAllSelectedDispatch<SetStateAction<boolean>>Sets the allSelected state-
rootboolean, 'indeterminate'Represents the root checkbox state-
setRootDispatch<SetStateAction<boolean>>Sets the root checkbox state-
selectedItemsIdsArray<string, number>Represents the state of the checkboxes-
setSelectedItemsIdsDispatch<SetStateAction<Array<string, number>>>Sets the checkboxes state-
selectionTreeSelectionTreeState<T>Selection tree state to be used within SelectionTree component-

BulkActions

It also receives the same properties as the div JSX element.

NameTypeDescriptionRequiredDefault
stateBulkActionsState<T>Bulk actions state-

Do’s

  1. The actions must always have an Icon and be of tertiary or criticalTertiary variants.