LLM-friendly URL

Filters

Introduction

luzmo-filters lets end users build and edit filters or filter groups for charts. Filters can be combined with AND/OR logic and nested into groups, giving users fine-grained control over the data they see.

The component outputs filters in the standard Luzmo filter format, so you can pass them directly to embedded visualizations or store them on items inside luzmo-item-grid .

Use the <luzmo-filters> element in your HTML.

Interactive example

Filters<luzmo-filters>
Live bar chart<luzmo-viz-item>

Properties

Use HTML attributes for primitive values in markup, and JS properties for objects, arrays, and programmatic updates.

Property HTML attribute Type Description
apiUrlapi-urlstring | undefined Luzmo API URL. Default: https://api.luzmo.com .
authKeyauth-keystring | undefined Auth key used by the data broker.
authTokenauth-tokenstring | undefined Auth token used by the data broker.
autofocusautofocusboolean When rendered, focus it automatically. Default: false .
cacheTimecache-timenumber | undefined Data broker cache time in ms.
contentLanguagecontent-languagestring Language used for locale-aware formatting and data labels. Default: en .
datasetIdsstring[] | undefined Dataset IDs used to load available columns/formulas. Required for editing.
debouncedebouncenumber Debounce time in ms for luzmo-filters-changed . Default: 300 .
disableddisabledboolean Disable this control. It will not receive focus or events. Default: false .
filtersItemFilterGroup[] Current filter groups (Luzmo filter format).
languagelanguagestring UI language. Default: en .
sizesize's' | 'm' | 'l' | 'xl' Component size.
tabIndextabindexnumber | undefined Tab index applied to this control.
timeZonetime-zonestring | undefined Time zone used by date pickers.

Events

Name Payload type Description
luzmo-filters-changedCustomEvent<{ filters: ItemFilterGroup[] }> Fired when filters change. Cancelable. Emission is debounced by debounce .

Types

The component entrypoint exports two component-owned types used by the internal filter editor. The shared type ItemFilterGroup is the external format consumed by Luzmo visualizations.

ts
import '@luzmo/analytics-components-kit/filters';

import type { FilterCondition, FilterGroup } from '@luzmo/analytics-components-kit/filters';
import type { ItemFilterGroup } from '@luzmo/analytics-components-kit/types';
Type Import path Description
ItemFilterGroup@luzmo/analytics-components-kit/types Shape of the filters property and the emitted value in luzmo-filters-changed . This is the standard Luzmo filter format, compatible with embedded visualizations and luzmo-item-grid items.
FilterGroup@luzmo/analytics-components-kit/filters Internal editable tree shape used by the filter editor UI. Represents a group with a condition ( and / or ), child filters, and nested sub-groups.
FilterCondition@luzmo/analytics-components-kit/filters Internal editable node shape inside a FilterGroup . Represents a single filter condition with an expression and parameters.

FilterGroup and FilterCondition are useful when you need to inspect or transform the editor's internal state, but they are not the format consumed by Luzmo visualizations -- use ItemFilterGroup for that.

The luzmo-filters-changed event does not currently have a named exported interface. Its payload shape is CustomEvent<{ filters: ItemFilterGroup[] }> .

CSS Variables

All CSS variables in this list can be set on luzmo-filters { ... } .

Variable Description
--luzmo-filters-font-family Font family.
--luzmo-filters-font-color Base text color.
--luzmo-filters-filters-list-gap Gap between filter rows.
--luzmo-filters-filter-line-gap Gap between filter content and the delete button.
--luzmo-filters-condition-warpper-width Width of the AND/OR condition column.
--luzmo-filters-condition-padding-horizontal Horizontal padding inside the condition badge.
--luzmo-filters-condition-badge-background Condition badge background color.
--luzmo-filters-condition-badge-background-hover Condition badge background on hover.
--luzmo-filters-condition-badge-color Condition badge text color.
--luzmo-filters-condition-badge-border-radius Condition badge border radius.
--luzmo-filters-condition-badge-halo Size of the halo behind the condition badge.
--luzmo-filters-vertical-line-color Color of the vertical connector line.
--luzmo-filters-vertical-line-width Width of the vertical connector line.
--luzmo-filters-vertical-line-top Top offset of the vertical connector line.
--luzmo-filters-vertical-line-bottom Bottom offset of the vertical connector line.
--luzmo-filters-nested-group-margin-top Margin above nested groups.
--luzmo-filters-nested-group-margin-bottom Margin below nested groups.
--luzmo-filters-group-actions-margin-top Margin above the group actions row.
--luzmo-filters-group-actions-gap Gap between group action buttons.
--luzmo-filters-group-actions-text-to-visual Spacing between action button text and icon.
--luzmo-filters-group-actions-color Action button color (default state).
--luzmo-filters-group-actions-color-hover Action button color on hover.
--luzmo-filters-group-actions-color-down Action button color on press.
--luzmo-filters-group-actions-color-focus Action button color on focus.
--luzmo-filters-add-root-group-container-margin-top Margin above the "Add group" UI when empty.
--luzmo-filters-add-group-button-text-to-visual Spacing between "Add group" text and icon.
--luzmo-filters-error-message-color Color used for the "dataset-ids missing" message.
--luzmo-filters-error-message-font-size Font size used for the "dataset-ids missing" message.

Code examples

index.html
Web component
Angular
React
React Native
Vue
<luzmo-filters
  id="filtersEditor"
  language="en"
  size="m"
  api-url="https://api.luzmo.com"
  auth-key="your-auth-key"
  auth-token="your-auth-token"
></luzmo-filters>

<script type="module">
  import '@luzmo/analytics-components-kit/filters';

  let filters = [
    {
      condition: 'and',
      filters: [
        {
          expression: '? in ?',
          parameters: [
            { columnId: '8ad1be07-cd5f-4170-b9c7-de1f0a2b4c78', datasetId: '6f2f9f80-3d80-4f45-9d5c-6d1b2e4a8c11' },
            ['Belgium']
          ]
        }
      ],
      subGroups: []
    }
  ];

  const filtersEditor = document.getElementById('filtersEditor');

  filtersEditor.datasetIds = ['6f2f9f80-3d80-4f45-9d5c-6d1b2e4a8c11'];
  filtersEditor.filters = filters;

  filtersEditor.addEventListener('luzmo-filters-changed', (event) => {
    filters = event.detail.filters;
    filtersEditor.filters = filters;
  });
</script>
Did this page help you?
Yes No