Action Config
Actions can be defined at zone-level (header/footer) and content-level (per-item).
ActionConfig Interface
interface ActionConfig<T = unknown> {
id: string;
label: string;
icon?: string;
variant?: string;
placement?: 'pinned' | 'onHover' | 'menu';
visibleIf?: (entity: T) => boolean;
onAction?: InteractionEventHandler;
}
Interactive Configurations
Zone Actions
Header and Footer Actions
Header and footer actions with pinned and menu placements.
zones: {
header: {
actions: [
{ id: 'add-user', label: 'Add User', icon: 'add', placement: 'pinned', variant: 'primary' },
{ id: 'export-csv', label: 'Export', icon: 'download', placement: 'menu' },
],
},
footer: {
actions: [{ id: 'settings', label: 'Settings', icon: 'settings', placement: 'menu' }],
},
}
Per-Item Actions
Item Actions with Overflow
Mixed action placements with overflow behavior and conditional visibility.
content: {
mode: 'table',
actions: [
{ id: 'edit', label: 'Edit', icon: 'edit', placement: 'pinned', variant: 'secondary' },
{ id: 'view', label: 'View', icon: 'view', placement: 'onHover' },
{
id: 'delete',
label: 'Delete',
icon: 'delete',
placement: 'menu',
variant: 'danger',
visibleIf: (entity) => entity.status === 'inactive',
},
],
actionOverflow: {
maxInline: { mobile: 1, tablet: 2, desktop: 3 },
menuLabel: 'More',
menuTooltip: 'More actions',
indicator: 'pulse',
},
item: { fields: [{ key: 'name' }, { key: 'status' }], layout: { type: 'auto' } },
}
Action Context Notes
ctx.entity is set for item actions; ctx.data and ctx.zone are set for zone actions.
ActionConfig Properties
| Property | Type | Description |
|---|---|---|
id | string | Stable action identifier (used in ctx.interactionId) |
label | string | Button label |
icon | string | Icon name (built-in or registered) |
variant | string | Visual variant. Common values in built-in examples include primary, secondary, danger, and ghost. |
placement | 'pinned' | 'onHover' | 'menu' | Where the action appears |
visibleIf | (entity) => boolean | Conditional visibility per item |
onAction | (ctx) => void | Local override (takes precedence over interactions.onEvent) |
Action Overflow
actionOverflow: {
maxInline: { mobile: 1, tablet: 2, desktop: 3 },
menuLabel: 'More',
menuTooltip: 'More actions',
indicator: 'pulse', // 'pulse' | 'scale' | 'color-shift' | 'none'
},
actionOverflow is available on both zone configs and ContentConfig.
Controls how zone and item actions behave when there are more actions than can fit inline.
The overflow button (⋯) appears automatically when actions are tucked into a menu.
When the overflow count increases (for example, after a container resize), the button plays
an attention animation defined by indicator.
indicator values
| Value | Effect |
|---|---|
'pulse' | Scale pop + blue radial ripple. Default. |
'scale' | Clean scale-only pop with no color change. |
'color-shift' | Brief background and border tint flash toward the primary color with no movement. |
'none' | Animation disabled entirely. |
The animation fires only when the overflow count increases, not on initial mount.
Reusable action presets
Widgemo ships coreActions presets you can spread into your own action objects.
Define only what is unique (id, label, placement, handlers), and inherit common preset fields (icon, default variant, and default visibility).
import { coreActions } from '@widgemo/widgemo-core';
actions: [
{ ...coreActions.edit, id: 'edit-user', label: 'Edit User', placement: 'pinned' },
{ ...coreActions.view, id: 'view-profile', label: 'View Profile', placement: 'onHover' },
{ ...coreActions.delete, id: 'delete-user', label: 'Delete User', placement: 'menu' },
]
Host-side shared presets (recommended)
For multiple widgemos, define shared host defaults once, then apply per-widget overrides:
import { coreActions } from '@widgemo/widgemo-core';
const HOST_ACTIONS = {
edit: { ...coreActions.edit, placement: 'pinned' as const },
view: { ...coreActions.view, placement: 'onHover' as const },
remove: { ...coreActions.delete, placement: 'menu' as const, variant: 'danger' as const },
};
const makeHostAction = (
type: keyof typeof HOST_ACTIONS,
overrides: Partial<typeof HOST_ACTIONS.edit> = {},
) => ({
...HOST_ACTIONS[type],
...overrides,
});
actions: [
makeHostAction('edit', { id: 'edit-user', label: 'Edit User' }),
makeHostAction('view', { id: 'view-profile', label: 'View Profile' }),
makeHostAction('remove', { id: 'delete-user', label: 'Delete User' }),
]
Preset Configuration
Core Action Presets
Uses coreActions plus host-side spread overrides.
import { coreActions } from '@widgemo/widgemo-core';
const config = {
zones: {
header: {
title: 'Team Directory',
actions: [
{ ...coreActions.add, id: 'add-user', label: 'Add User', placement: 'pinned', variant: 'primary' },
{ ...coreActions.refresh, id: 'sync-users', label: 'Sync', placement: 'pinned', variant: 'secondary' },
{ ...coreActions.export, id: 'export-users', label: 'Export Users', placement: 'menu' },
],
},
content: {
mode: 'table',
item: { fields: [{ key: 'name', label: 'Name' }, { key: 'status', label: 'Status' }], layout: { type: 'auto' } },
actions: [
{ ...coreActions.edit, id: 'edit-user', label: 'Edit User', placement: 'pinned' },
{ ...coreActions.view, id: 'view-profile', label: 'View Profile', placement: 'onHover' },
{
...coreActions.delete,
id: 'delete-user',
label: 'Delete User',
placement: 'menu',
variant: 'danger',
visibleIf: (entity) => entity.status === 'inactive',
},
],
actionOverflow: { maxInline: { mobile: 1, tablet: 2, desktop: 2 }, menuLabel: 'More', indicator: 'pulse' },
},
},
};
coreActions
Built-in action presets for common operations. Use them directly as ActionConfig entries or spread them to override fields:
import { coreActions } from '@widgemo/widgemo-core';
// Use a preset directly
actions: [coreActions.view, coreActions.export]
// Override a field on a preset
actions: [{ ...coreActions.export, label: 'Export Users', placement: 'pinned' }]
Built-in presets: add, refresh, viewToggle, export, import, settings, view, edit, delete, filter, sort, search.
See Also
- Widgemo Config — zone header/footer where
actionsarrays are placed - Zone Config — zone-level
actionsandactionOverflow - Content Config —
ContentConfig.actionsfor per-item actions - Extension API —
InteractionContextshape received byonAction - Item Config — item structure used alongside per-item actions
- All Exports — complete named export index