You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An ActionBar is a companion component intended to facilitate bulk actions on selected items within a collection component. It consists of an ActionGroup, a clear button, and a count of selected items. It accepts a list of <TypeLinklinks={docs.links}type={docs.exports.Item} />
95
86
elements as children, each with a `key` prop. Alternatively, a function that returns `Item` elements is also supported as seen below. See the [collection components](../react-stately/collections.html)
96
-
docs for more details about this API. These `Item` elements are used to populate the ActionBar's ActionGroup and thus follows the [same content guidelines](./ActionGroup.html#content)when it comes to customization and labeling.
87
+
docs for more details about this API. These `Item` elements are used to populate the buttons in the ActionBar, and follows the [ActionGroup content guidelines](./ActionGroup.html#content)for customization and labeling.
97
88
98
89
```tsx example
99
90
function Example() {
@@ -103,28 +94,20 @@ function Example() {
103
94
{key: 'delete', label: 'Delete'}
104
95
];
105
96
106
-
let listItems = [
107
-
{key: 0, name: 'Adobe Photoshop'},
108
-
{key: 1, name: 'Adobe Illustrator'},
109
-
{key: 2, name: 'Adobe XD'}
110
-
];
111
-
112
-
let [selectedKeys, setSelectedKeys] =React.useState(newSet([0]));
97
+
let [selectedKeys, setSelectedKeys] =React.useState(newSet(['photoshop']));
<ListViewitems={listItems}aria-label="ListView with action bar, dynamic collection"selectionMode="multiple"selectedKeys={selectedKeys}onSelectionChange={setSelectedKeys}>
117
-
{(item) => (
118
-
<Item>
119
-
{item.name}
120
-
</Item>
121
-
)}
101
+
<ListViewaria-label="ListView with action bar"selectionMode="multiple"selectedKeys={selectedKeys}onSelectionChange={setSelectedKeys}>
@@ -148,43 +131,28 @@ automatically. For languages that are read right-to-left (e.g. Hebrew and Arabic
148
131
149
132
## Events
150
133
Use the `onClearSelection` prop as a callback to handle when the clear button in the ActionBar is pressed. Additionally, the `onAction` prop can be used as a callback for when the user
151
-
presses any of the buttons in the ActionBar's ActionGroup. The `key` from the pressed button will be passed into the callback.
134
+
presses any of the buttons in the ActionBar. The `key` from the pressed `<Item>` will be passed to the callback.
152
135
153
136
The following example clears row selection within the TableView when the clear button is pressed and alerts the user as to what
154
-
action is being taken on the selected rows when the ActionButtons are pressed.
137
+
action is being taken on the selected rows when the buttons are pressed.
155
138
156
139
```tsx example
157
140
function ActionBarActions(props) {
158
-
// Same bar items, table columns, and table rows as example above...
159
-
///- begin collapse -///
160
-
let columns = [
161
-
{name: 'Name', uid: 'name'},
162
-
{name: 'Type', uid: 'type'},
163
-
{name: 'Level', uid: 'level'}
164
-
];
141
+
let [selectedKeys, setSelectedKeys] =React.useState(newSet([2]));
let [selectedKeys, setSelectedKeys] =React.useState(newSet([2]));
178
-
///- end collapse -///
148
+
179
149
return (
180
150
<ActionBarContainerheight="size-5000">
181
-
<TableViewaria-label="Table with action bar and controlled selection"selectionMode="multiple"selectedKeys={selectedKeys}onSelectionChange={setSelectedKeys}height="size-3000">
<TableViewaria-label="Table with action bar and controlled selection"selectionMode="multiple"selectedKeys={selectedKeys}onSelectionChange={setSelectedKeys}>
152
+
<TableHeader>
153
+
<Columnkey="name">Name</Column>
154
+
<Columnkey="type">Type</Column>
155
+
<Columnkey="level"align="end">Level</Column>
188
156
</TableHeader>
189
157
<TableBodyitems={rows}>
190
158
{item=> (
@@ -195,20 +163,22 @@ function ActionBarActions(props) {
0 commit comments