Home > widget-integration > FilterController > handleTextSwatch
FilterController.handleTextSwatch() method
Handles text-based swatch display. Updates label and tooltip text content with custom text from settings.
Signature:
protected handleTextSwatch(label: HTMLElement, tooltip: HTMLElement | null, swatchObj: {
text?: string;
}): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
label |
HTMLElement |
The swatch label element |
|
tooltip |
HTMLElement | null |
The tooltip element (optional) |
|
swatchObj |
{ text?: string; } |
Swatch settings object containing text property |
Returns:
void
Remarks
Text swatches display custom text instead of the original variant value. This is useful for abbreviations, translations, or custom naming.
Example
Override to add text transformations:
window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
return class CustomFilterController extends FilterController {
protected handleTextSwatch(label, tooltip, swatchObj) {
super.handleTextSwatch(label, tooltip, swatchObj);
// Uppercase all text swatches
if (label.textContent) {
label.textContent = label.textContent.toUpperCase();
}
}
};
});