ComPDFKit Web SDK
    Preparing search index...

    Class ToolButton

    A button that activates a tool (by tool name) when clicked and shows as active while that tool is in use.

    const rectangleButton = new instance.UI.Components.ToolButton({
    dataElement: 'myRectangleButton',
    toolName: instance.Core.Tools.ToolNames.RECTANGLE,
    });
    const header = instance.UI.getModularHeader('default-top-header');
    header.setItems([...header.getItems(), rectangleButton]);

    Hierarchy (View Summary)

    Index
    • Replaces the inline CSS styles of the item and updates it on screen when it is already in the UI.

      Parameters

      • style: Record<string, unknown>

        CSS property names (camelCase) mapped to their values.

      Returns void

    className?: string

    Extra CSS class names added to the item's element.

    color?: string

    Icon color of the button.

    dataElement: string

    Unique name of the item; used to find, show, hide or update it later.

    disabled?: boolean

    Whether the item is disabled (rendered but not clickable).

    hidden?: boolean | string[]

    Hides the item: true always hides it; an array of screen sizes ('desktop', 'tablet', 'mobile', 'small-mobile') hides it only on those screen sizes.

    img?: string

    Icon of the button; defaults to the icon of the tool.

    isActive?: boolean

    Whether the button is shown as active.

    label?: string

    Text shown on the button, or a translation key.

    onClick?: unknown

    Called when the button is clicked, in addition to activating the tool.

    style?: Record<string, unknown>

    Inline CSS styles applied to the item's element.

    title?: string

    Tooltip text, or a translation key that is resolved in the current language.

    toolName?: string

    Name of the tool the button activates (a value of Core.Tools.ToolNames or a registered custom tool).

    type?: string

    Item type (for example 'customButton', 'toolButton', 'divider'); set by each subclass.