Home > widget-integration > FilterRender > createButtonClearOrClearAll

FilterRender.createButtonClearOrClearAll() method

Creates a clear or clear-all button element for the mobile filter toolbar.

Generates a <button> pre-configured with the correct action metadata for either clearing a single filter option or all active filters.

Signature:

createButtonClearOrClearAll(type?: "clearAll" | "clear", optionId?: string): HTMLButtonElement;

Parameters

Parameter

Type

Description

type

"clearAll" | "clear"

(Optional) Button type: 'clearAll' removes all filters, 'clear' removes one option (default: 'clearAll')

optionId

string

(Optional) Required when type is 'clear'; the filter option ID to clear

Returns:

HTMLButtonElement

A configured HTMLButtonElement ready to append to the toolbar

Example

Override to customize button appearance:

window.boostWidgetIntegration.extend('FilterRender', (FilterRender) => {
  return class extends FilterRender {
    createButtonClearOrClearAll(type, optionId) {
      const btn = super.createButtonClearOrClearAll(type, optionId);
      btn.classList.add('shop-custom-clear-btn');
      return btn;
    }
  };
});