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
console.log(`Action "${actionKey}" triggered on item "${itemKey}"`);
392
+
};
393
+
394
+
return(
395
+
<CommandMenu
396
+
id="command-menu-with-actions"
397
+
{...props}
398
+
searchPlaceholder="Search files..."
399
+
autoFocus={true}
400
+
width="20x 50x"
401
+
onAction={handleAction}
402
+
>
403
+
<CommandMenu.Item
404
+
key="file1"
405
+
icon={<IconBook/>}
406
+
description="PDF document"
407
+
actions={
408
+
<>
409
+
<ItemAction
410
+
icon={<EditIcon/>}
411
+
aria-label="Edit"
412
+
onPress={()=>handleItemAction('file1','edit')}
413
+
/>
414
+
<ItemAction
415
+
icon={<ClearIcon/>}
416
+
aria-label="Delete"
417
+
onPress={()=>handleItemAction('file1','delete')}
418
+
/>
419
+
</>
420
+
}
421
+
>
422
+
Document.pdf
423
+
</CommandMenu.Item>
424
+
<CommandMenu.Item
425
+
key="file2"
426
+
icon={<IconReload/>}
427
+
description="Backup file"
428
+
actions={
429
+
<>
430
+
<ItemAction
431
+
icon={<EditIcon/>}
432
+
aria-label="Edit"
433
+
onPress={()=>handleItemAction('file2','edit')}
434
+
/>
435
+
<ItemAction
436
+
icon={<ClearIcon/>}
437
+
aria-label="Delete"
438
+
onPress={()=>handleItemAction('file2','delete')}
439
+
/>
440
+
</>
441
+
}
442
+
>
443
+
Backup.zip
444
+
</CommandMenu.Item>
445
+
<CommandMenu.Item
446
+
key="file3"
447
+
icon={<IconPlus/>}
448
+
description="New file"
449
+
actions={
450
+
<>
451
+
<ItemAction
452
+
icon={<EditIcon/>}
453
+
aria-label="Edit"
454
+
onPress={()=>handleItemAction('file3','edit')}
455
+
/>
456
+
<ItemAction
457
+
icon={<ClearIcon/>}
458
+
aria-label="Delete"
459
+
onPress={()=>handleItemAction('file3','delete')}
460
+
/>
461
+
</>
462
+
}
463
+
>
464
+
Project.doc
465
+
</CommandMenu.Item>
466
+
<CommandMenu.Item
467
+
key="file4"
468
+
icon={<IconBulb/>}
469
+
description="No actions"
470
+
>
471
+
Item without actions
472
+
</CommandMenu.Item>
473
+
</CommandMenu>
474
+
);
475
+
};
476
+
477
+
ItemsWithActions.parameters={
478
+
docs: {
479
+
description: {
480
+
story:
481
+
'Demonstrates CommandMenu.Item with inline actions. Actions are displayed on the right side of each item and inherit the item type through ItemActionProvider context. Search to filter items and hover to see the actions.',
-**Description**: Inline action buttons displayed on the right side of the button. Use `ItemButton.Action` for consistent styling. Actions automatically inherit the parent button's `type` prop and the component reserves space to prevent content overlap.
45
+
40
46
### Action Properties
41
47
42
48
#### onPress
@@ -161,6 +167,27 @@ Inherits all modifiers from [ItemBase](/docs/content-itembase--docs) plus:
161
167
</ItemButton>
162
168
```
163
169
170
+
### Button with Actions
171
+
172
+
ItemButton supports inline actions that appear on the right side. Use the `ItemButton.Action` compound component for consistent styling:
Actions automatically inherit the parent button's `type` prop and adjust their styling accordingly. The component reserves space for actions to prevent content overlap.
190
+
164
191
## Accessibility
165
192
166
193
### Keyboard Navigation
@@ -207,13 +234,46 @@ Inherits all modifiers from [ItemBase](/docs/content-itembase--docs) plus:
207
234
</ItemButton>
208
235
```
209
236
210
-
4.**Don't**: Use vague or unclear button text
237
+
4.**Do**: Use `ItemButton.Action` for inline actions
7.**Don't**: Overcrowd buttons with too many visual elements
217
277
```jsx
218
278
{/* Avoid this - too many competing elements */}
219
279
<ItemButton
@@ -227,7 +287,7 @@ Inherits all modifiers from [ItemBase](/docs/content-itembase--docs) plus:
227
287
</ItemButton>
228
288
```
229
289
230
-
6.**Accessibility**: Always ensure buttons have clear, descriptive labels and proper keyboard support
290
+
8.**Accessibility**: Always ensure buttons have clear, descriptive labels, proper keyboard support, and provide `aria-label` for action buttons
231
291
232
292
## Integration with Forms
233
293
@@ -248,6 +308,7 @@ ItemButton integrates seamlessly with forms when using the `buttonType` prop:
248
308
## Related Components
249
309
250
310
-[ItemBase](/docs/content-itembase--docs) - The foundational component that ItemButton extends
311
+
-[ItemButton.Action](/docs/actions-itemaction--docs) - Action button component for inline actions (also available as `ItemBase.Action`, `Menu.Item.Action`, etc.)
251
312
-[Button](/docs/actions-button--docs) - Traditional button component for simpler use cases
252
313
-[Link](/docs/navigation-link--docs) - Text link component for navigation
253
314
-[Menu.Item](/docs/actions-menu--docs) - Menu item component that also uses ItemBase
0 commit comments