ComPDFKit Web SDK
    Preparing search index...

    Class ModularHeader

    A header bar placed on one side of the viewer that holds items and groups.

    const { ModularHeader, PresetButton, Zoom } = instance.UI.Components;
    const bottomHeader = new ModularHeader({
    dataElement: 'myBottomHeader',
    placement: 'bottom',
    justifyContent: 'center',
    items: [
    new Zoom({ dataElement: 'bottomZoom' }),
    new PresetButton({ dataElement: 'bottomDownloadButton', buttonType: instance.UI.PRESET_BUTTON_TYPES.DOWNLOAD }),
    ],
    });
    instance.UI.addModularHeaders([bottomHeader]);
    Index
    • Creates a header.

      Parameters

      • props: ItemOptions

        dataElement and placement (required), items, gap, grow, justifyContent, position, float, maxWidth, maxHeight, opacityMode, opacity, stroke, style, label.

      Returns ModularHeader

    • Returns the grouped items of the header.

      Returns (string | object)[]

      Items whose type is 'groupedItems'.

    • Returns the items of the header, optionally only those of one type.

      Parameters

      • Optionaltype: string

        Item type to keep, for example 'groupedItems' or 'toolButton'.

      Returns (string | object)[]

      The matching items.

    • Sets the space between items. Invalid values are ignored with a warning.

      Parameters

      • gap: number

        Space in pixels.

      Returns void

    • Replaces the items of the header. Items of unknown types are dropped with a warning; new item objects are registered in the UI.

      Parameters

      • newItems: object | (string | object)[]

        An item or an array of items (objects or dataElements of existing items).

      Returns void

      const header = instance.UI.getModularHeader('default-top-header');
      // Remove the search button
      header.setItems(header.getItems().filter(item => item.dataElement !== 'searchPanelToggle'));
    • Sets how items are distributed along the header. Invalid values are ignored with a warning.

      Parameters

      • justifyContent: string

        One of 'start', 'end', 'center', 'space-between', 'space-around', 'space-evenly'.

      Returns void

    • Sets the maximum height of the header. Negative or non-numeric values are ignored with a warning.

      Parameters

      • maxHeight: number

        Height in pixels.

      Returns void

    • Sets the maximum width of the header. Negative or non-numeric values are ignored with a warning.

      Parameters

      • maxWidth: number

        Width in pixels.

      Returns void

    • Replaces the inline CSS styles of the header and updates it on screen.

      Parameters

      • style: Record<string, unknown>

        CSS property names (camelCase) mapped to their values.

      Returns void

    dataElement: string

    Unique name of the header.

    float: boolean

    Whether the header floats over the document instead of taking its own space.

    gap: number

    Space between items, in pixels.

    grow: number

    Flex grow factor of the header (kept with the header data).

    items: (string | object)[]

    Items in the header, in display order.

    justifyContent?: string

    How items are distributed along the header ('start', 'end', 'center', 'space-between', 'space-around' or 'space-evenly').

    label?: string

    Optional label of the header.

    maxHeight?: number

    Maximum height of the header, in pixels.

    maxWidth?: number

    Maximum width of the header, in pixels.

    opacity?: string

    Opacity level of a floating header: 'full' (default), 'low' or 'none'.

    opacityMode?: string

    Opacity mode of a floating header: 'static' (default) or 'dynamic' (becomes opaque on hover or focus).

    placement: string

    Side of the viewer the header is placed on: 'top', 'bottom', 'left' or 'right'.

    position?: string

    Position of a floating header along its side: 'start' (default), 'center' or 'end'.

    stroke: boolean

    Whether the header draws a border on the side facing the document; true by default.

    style: Record<string, unknown>

    Inline CSS styles applied to the header element.

    type: string

    Item type: 'modularHeader'.