Lime Web Components API Documentation - v6.27.0
    Preparing search index...

    Interface Action<T>Beta

    Represents a user-triggerable action that can be displayed in various UI contexts.

    Actions are the primary way to expose functionality to users through the UI. They can appear as:

    • Toolbar buttons
    • Dropdown menu options
    • Quick action buttons

    Each action wraps a command that executes when the action is triggered. Actions can be conditionally shown or hidden using Conditions, and they support rich metadata like icons, labels, and descriptions for better UX.

    The generic type parameter T allows you to specify the exact command type, enabling type-safe action definitions for specific contexts like single objects or bulk operations.

    Basic action with icon and label

    const actions = [
    {
    label: 'Save',
    icon: 'save',
    command: new SaveRecordCommand()
    },
    {
    label: 'Delete',
    icon: 'trash',
    command: new DeleteRecordCommand()
    }
    ];

    Conditional action with icon-only display

    const canSendEmail = {
    id: 'contact.can-send-email',
    type: 'limeobject',
    evaluate: (contact) => contact.email && contact.email.length > 0
    };

    const sendEmailAction = {
    label: 'Send Email',
    icon: 'envelope',
    hideLabel: true,
    command: new SendEmailCommand(),
    condition: canSendEmail
    };

    Action with description and disabled state

    const exportAction = {
    label: 'Export to Excel',
    description: 'Download this record as an Excel spreadsheet',
    icon: 'file-excel',
    command: new ExportExcelCommand(),
    disabled: !object || !object.id
    };
    interface Action<T extends AnyCommand = AnyCommand> {
        command: T;
        condition?: Condition;
        description?: string;
        disabled?: boolean;
        hideLabel?: boolean;
        icon?: string | Icon;
        label?: string;
        rules?: { visibility?: Rule };
    }

    Type Parameters

    Index

    Properties

    command: T

    The command to execute when the action is activated.

    This command will be dispatched to the CommandBus when the user triggers the action. The command type determines what operation will be performed (e.g., save, delete, export, send email).

    condition?: Condition

    Optional condition that determines whether the action is available.

    If provided, the condition's evaluate function will be called to determine if the action should be shown or enabled. If the condition evaluates to false, the action is typically hidden from the UI.

    This is particularly useful for:

    • Showing actions only for objects in specific states
    • Permission-based action visibility
    • Context-dependent action availability
    const canDelete: LimeObjectCondition = {
    id: 'record.can-delete',
    type: 'limeobject',
    evaluate: (obj) => !obj.locked
    };

    const deleteAction: LimeObjectAction = {
    label: 'Delete',
    command: new DeleteObjectCommand(),
    condition: canDelete
    };

    Use rules.visibility instead. When both are set, action-menu surfaces evaluate rules.visibility and ignore condition. Migrating an action to rules.visibility for visibility requires the useRuleVisibility feature switch to be enabled. While it is off, surfaces keep evaluating condition.

    description?: string

    Additional descriptive text explaining what the action does.

    Descriptions provide more context than labels alone and are typically displayed in:

    • Tooltips on hover
    • Help text in configuration dialogs
    • Extended menu descriptions

    Use descriptions to clarify the action's purpose or any side effects.

    {
    label: 'Export to Excel',
    description: 'Download all selected records as an Excel spreadsheet',
    command: { name: 'export-excel' }
    }
    disabled?: boolean

    Controls whether the action is disabled (grayed out but visible).

    When true, the action is shown in the UI but cannot be triggered. This is different from hiding the action entirely (using condition).

    Use disabled state to:

    • Indicate that an action exists but is temporarily unavailable
    • Show what actions would be available in different contexts
    • Provide better user feedback than simply hiding the action
    {
    label: 'Save',
    icon: 'save',
    command: new SaveCommand(),
    disabled: !this.hasUnsavedChanges
    }
    hideLabel?: boolean

    Controls whether the action's label should be hidden in the UI.

    When true, only the icon is displayed, creating a more compact interface. However, the label should still be provided for:

    • Accessibility (screen readers)
    • Tooltips on hover
    • Alternative display contexts (e.g., dropdown menus)

    Icon-only actions work best in toolbars where space is limited and icons are easily recognizable.

    icon?: string | Icon

    Icon to display with the action.

    Can be either a string referencing an icon name from the platform's icon library, or an Icon object with additional properties like color.

    Icons help users quickly identify actions and improve visual scannability of action menus and toolbars.

    Icon

    label?: string

    Display label for the action.

    This text is shown to the user in menus, buttons, or tooltips. The label is automatically translated using the platform's Translator service, so you should provide translation keys rather than hardcoded strings.

    Even if hideLabel is true, you should still provide a label for accessibility and alternative display contexts.

    rules?: { visibility?: Rule }

    Optional behavior rules.

    Type Declaration

    • Optionalvisibility?: Rule

      Rule that gates whether the action is visible.

      rules.visibility only gates action visibility while the useRuleVisibility feature switch is enabled. While it is off, surfaces fall back to the legacy condition.

      If both rules.visibility and the legacy condition are set on the same action, action-menu surfaces evaluate rules.visibility and ignore condition.

      Hide a delete action unless the user is an admin and the deal is still open:

      const deleteAction: LimeObjectAction = {
      label: 'Delete',
      command: new DeleteObjectCommand(),
      rules: {
      visibility: {
      type: 'all',
      rules: [
      {
      type: 'ref',
      id: 'limetech.user-has-role',
      args: { roles: ['admin'] },
      },
      { type: 'ref', id: 'mycorp.deal-is-open' },
      ],
      },
      },
      };

    Rule