The page navigation is complete. You may now navigate the page content as you wish.
Skip to main content

Filter Bar

Updated in v6.1.0

A composition of HDS components to support filtering.

The Filter Bar is used to apply and display filters to a data set. It is most often used with the Advanced Table, but is flexible enough to support the standard Table, lists, or a grid of cards.

The Filter Bar is a successor to the Filter pattern and supports the vast majority of filtering experiences within HashiCorp applications out of the box. New experiences should use the Filter Bar directly, while already delivered features should consider migrating to the component.

If specific functionality or filtering methods don't meet your needs, please contact the Design Systems Team so we can help.

Usage

When to use

  • When displaying filters for a data set.
  • As a replacement for the HDS Filter pattern.

When not to use

  • For complex query builder features.

Type

Differences between Figma and code

The type property is only available in Figma. The Ember component can be passed to the Advanced Table as a contextual component, or used on its own in which case the styling will adjust accordingly.

The Filter Bar supports two visual presentations, attached and standalone, to be used in different contexts and with different types of data sets.

Attached

Use the attached variant with the Advanced Table to clearly associate the Filter Bar with the rendered data set and the table.

Example of an attached Filter Bar paired with a data set rendered in an Advanced Table

Standalone

Use the standalone variant when a data set is rendered in formats other than the Advanced Table, e.g., a standard Table, list, or grid of cards.

Example of a standalone Filter Bar paired with a data set rendered in cards

Applying Filters

Filters can be applied on a per-filter basis or via live filtering.

  • Per-filter: filters are applied when the user confirms their selection with the "Apply filters" button in the dropdown. This is the most common method.
  • Live filtering: filters are applied immediately upon selection.

Applied filters

Applied filters are represented by a Tag displaying the filter parameter (the category or column the filter corresponds to) and the filter value (corresponding with the specific cell content).

By default, the text rendered within the Tag uses a standardized format depending on the type of filter:

  • Single and multiple selection filters group the parameter and value using a colon, e.g., "Region: AWS (us-east)"
  • Numerical filters group the parameter and value with an operator symbols, e.g., "Modules > 50"
  • Date and time filters group the parameter and value with natural language, e.g., "Created before 12:00 PM"

If necessary, the text can be overridden within the Tag. This can be useful if the parameter label is an irregular plural, if the parameter reads more naturally with certain punctuation or grammar, or for product-specific reasons.

The Tag component truncates at roughly 20 characters.

Expand & collapse

The applied filters section can be collapsed to simplify the UI or expanded to bring focus to the data. This is helpful when many filters are applied or when the data set is complex.

An example of the collapsed state of the Filter Bar

When no filters are applied, the applied filters section is collapsed by default and will display an empty state message when expanded.

An example of the expanded Filter Bar with no filters applied and an empty state

When one or more filters are applied, the Filter Bar is expanded by default.

An example of the expanded Filter Bar with several filters applied

Clearing filters

All filters can be cleared in bulk using the "Clear All" button near the applied filters or in the dropdown footer.

Filters can also be cleared individually via the Tag's dismiss button.

When multiple filter values are selected for a single parameter or input fields define the filter, the "Clear selection" button in the dropdown deselects all values for that parameter.

Use the search input to apply a broad text filter across the entire data set.

An example of the term "errored" searched for across the entire data set

Bulk actions

Bulk actions, corresponding to our recommendations for multi-select, can be used to perform actions across multiple results, such as editing, deleting, and selecting subsets of the data set.

Example of bulk actions

Generic content

Custom functionality can be added to or replace the Bulk action dropdown. We recommend limiting this to actions or information that directly tie back to the data set.

Example of generic content

Filter dropdown

The Filter Bar includes a complex dropdown menu that displays available filter parameters, the values within each parameter, support for numerical/date/time values, value ranges, and actions to apply and clear filters.

The Filter Dropdown is responsible for the selection and application of filters and is broken into two "panels":

  • The left panel displays the list of parameters (categories) that can be filtered upon.
  • The right panel displays a list of options or a group of input fields (for numerical, date, or time values).

Multi-selection

Selecting multiple values from a list of options is one of the most common filtering methods. It's best suited for categorical data like statuses, but can also be used more generally to filter by a handful of text or string values.

Single-selection

Selecting one value from a list of options is best suited for filter values that cannot be selected simultaneously, helping prevent an empty state.

Numbers, dates, times, and datetimes

By combining an operator (greater than, less than, before, etc.) with input fields, filtering by numerical values, dates, times, and datetimes can be handled. This filtering method is best suited for range-based filtering, i.e., filtering based on comparisons of values or ranges of values.

For a full list of supported operators, visit the specifications page.

Custom filtering

While the left panel should always display the list of parameters, the right panel can be customized to meet filtering requirements beyond the out-of-the-box methods.

Search across filter values

Users can search across all values within a selected parameter. While search is relevant only for single- or multi-selection, it can be especially useful when there are many values or when a unique naming convention is used.

How to use this component

The Filter Bar component is used to apply and display filters to a data set. The component does not handle any filtering of the data itself, but provides a way for a user to apply filters, and a means for displaying any filters that have been applied.

To use this component, set the filter options available for a data set using the FiltersDropdown and FilterGroup contextual components. When filters are applied, the @onFilter callback provides a data object of the applied filters. To show which filters have been applied, pass a data object of the same structure to the @filters argument.

The Filter Bar is also available as a contextual component of the Advanced Table.


Project: Project 1 Project: Project 2 Version: 1.0

Filters Dropdown

All filtering options are available via a dropdown in the Filter Bar. Inside the dropdown, each filter group is represented with its own tab. When a tab is selected, the filtering options available are visible and users can add filters for that group. By clicking the "Apply filters" or "Clear all filters" buttons in the dropdown footer, the user can apply the selected filters, or clear all that have been previously set.

Filtering options are passed to the Filter Bar through the FiltersDropdown and FilterGroup contextual components. In the FilterGroup, the @key, @text, and @type arguments are required.

  • The @key argument sets the key for that filter group in the data object of the onFilter callback.
  • The @text argument sets the text for tab label.
  • The @type argument specifies the type of filtering available for the group.

View more details on available filter types below.

<Hds::FilterBar @filters={{this.demoEmptyFilters}} @onFilter={{this.demoUpdateEmptyFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-multi-select" @text="Multi-select" @type="multi-select" as |F|>
      <F.Checkbox @value="option-1" @label="Option 1" />
      <F.Checkbox @value="option-2" @label="Option 2" />
      <F.Checkbox @value="option-3" @label="Option 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="demo-single-select" @text="Single-select" @type="single-select" as |F|>
      <F.Radio @value="option-1" @label="Option 1" />
      <F.Radio @value="option-2" @label="Option 2" />
      <F.Radio @value="option-3" @label="Option 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="demo-number" @text="Number" @type="numerical" />
    <D.FilterGroup @key="date" @text="Date" @type="date" />
    <D.FilterGroup @key="demo-time" @text="Time" @type="time" />
    <D.FilterGroup @key="demo-datetime" @text="Datetime" @type="datetime" />
  </F.FiltersDropdown>
</Hds::FilterBar>

Applying filters

A user can apply, update, or clear filters within the dropdown. The @onFilter callback is used to listen for and respond to changes to the filters.

The callback provides a data object of applied filters which come from a user's filter selections. This object can be used to run any filtering operations on a data set, and then be passed back into the @filters argument of the Filter Bar to show the applied filters.

Based on the applied filters passed to the @filters argument, dismissible Tags will be shown for each applied filter. When a Tag is dismissed, the @onFilter callback will be triggered, and that filter will be removed from the object.


Project: Project 1 Project: Project 2 Version: 1.0
<Hds::FilterBar @filters={{this.demoFilters}} @onFilter={{this.demoUpdateFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>

Live filtering

By default, the @onFilter callback is not triggered when a filter is added in the dropdown. Instead, the callback is triggered when the user confirms their filters with the "Apply filters" button, or clears them with the "Clear all filters" button.

If the @isLiveFilter argument is set to true, the @onFilter callback will be triggered as soon as a user adds a filter in the dropdown. If it is a selection-based filter, like a checkbox or radio button, the filtering would occur on selection. If it is an input-based filter, like a date or number, the filter would be applied when both inputs are correctly filled out.

Filters will be applied automatically as selections are made
<Hds::FilterBar
  @filters={{this.demoLiveFilters}}
  @isLiveFilter={{true}}
  @onFilter={{this.demoUpdateLiveFilters}}
  as |F|
>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
    <D.FilterGroup @key="creation-date" @text="Creation date" @type="date" />
  </F.FiltersDropdown>
</Hds::FilterBar>

Filter types

The Filter Bar includes distinct filter groups to accommodate various data types.

Single-select and Multi-select

The single-select and multi-select filter types are used for filtering a list of items by one or multiple values. The options available for selection can be set using the Radio and Checkbox contextual components inside the FilterGroup.

If the @searchEnabled argument in the FilterGroup is set to true, the list of options can be searched through using a provided search input.

The dismissible filter tag will display the label for a given filter, and if the label is not provided it will display the value.


Single-select: Option 1 Multi-select: Option 1 Multi-select: Option 2
<Hds::FilterBar @filters={{this.demoSelectionFilters}} @onFilter={{this.demoUpdateSelectionFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-single-select" @text="Single-select" @type="single-select" @searchEnabled={{true}} as |F|>
      <F.Radio @value="option-1" @label="Option 1" />
      <F.Radio @value="option-2" @label="Option 2" />
      <F.Radio @value="option-3" @label="Option 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="demo-multi-select" @text="Multi-select" @type="multi-select" @searchEnabled={{true}} as |F|>
      <F.Checkbox @value="option-1" @label="Option 1" />
      <F.Checkbox @value="option-2" @label="Option 2" />
      <F.Checkbox @value="option-3" @label="Option 3" />
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoSelectionFilters = {
  'demo-single-select': {
    type: 'single-select',
    text: 'Single-select',
    data: {
      value: 'option-1',
      label: 'Option 1',
    },
  },
  'demo-multi-select': {
    type: 'multi-select',
    text: 'Multi-select',
    data: [
      { value: 'option-1', label: 'Option 1' },
      { value: 'option-2', label: 'Option 2' },
    ],
  }
};

Numerical

The numerical filter type is used for any data which is numerical in nature. It provides options for all comparison operators including a between selector.


Numerical A < 10 Numerical B between 10 and 20
<Hds::FilterBar @filters={{this.demoNumericalFilters}} @onFilter={{this.demoUpdateNumericalFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-numerical-a" @text="Numerical A" @type="numerical" />
    <D.FilterGroup @key="demo-numerical-b" @text="Numerical B" @type="numerical" />
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoNumericalFilters = {
  'demo-numerical-a': {
    type: 'numerical',
    text: 'Numerical A',
    data: {
      selector: 'less-than',
      value: 10,
    },
  },
  'demo-numerical-b': {
    type: 'numerical',
    text: 'Numerical B',
    data: {
      selector: 'between',
      value: {
        start: 10,
        end: 20,
      }
    },
  }
};

Date & time

There are filter types available for various date and time data through the date, time, and datetime filter types. All three types also support the between selector.

Dates and times are formatted in the applied filter tags using the ember-intl service.


Date before 1/1/25 Time before 8:00 PM Datetime before 1/1/25, 12:00 PM Date range between 1/1/24 and 1/1/25
<Hds::FilterBar @filters={{this.demoDateTimeFilters}} @onFilter={{this.demoUpdateDateTimeFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-date" @text="Date" @type="date" />
    <D.FilterGroup @key="demo-time" @text="Time" @type="time" />
    <D.FilterGroup @key="demo-datetime" @text="Datetime" @type="datetime" />
    <D.FilterGroup @key="demo-date-range" @text="Date range" @type="date" />
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoDateTimeFilters = {
  'demo-date': {
    type: 'date',
    text: 'Date',
    data: {
      selector: 'before',
      value: '2025-01-01',
    },
  },
  'demo-time': {
    type: 'time',
    text: 'Time',
    data: {
      selector: 'before',
      value: '20:00',
    },
  },
  'demo-datetime': {
    type: 'datetime',
    text: 'Datetime',
    data: {
      selector: 'before',
      value: '2025-01-01T12:00',
    },
  },
  'demo-date-range': {
    type: 'date',
    text: 'Date range',
    data: {
      selector: 'between',
      value: {
        start: '2024-01-01',
        end: '2025-01-01',
      }
    },
  }
};

Custom filtering

Consumer responsibility

The accessibility compliance of any content used for a custom filter is the responsibility of the consumer. If a custom filter requires multiple form elements, it is recommended to use a <fieldset> element to group them.

For filtering support outside of the filter types supported above, an option for more customized filtering is available through the generic filter type, and the Generic contextual component inside the FilterGroup. The Generic contextual component provides an updateFilter argument function that can be used to trigger updates to the filter inside the dropdown.

The dismissible filter tag can be customized by setting dismissTagText on the filter. If this is not provided, the dismissible filter tag's text will function similarly to the single-select and multi-select filter types, where the value or label is displayed.

The @onClear callback can be used to listen to the FilterGroup "Clear filter" button, and reset any content inside your filter such as clearing a form input.


Generic equals Name
<Hds::FilterBar @filters={{this.demoGenericFilters}} @onFilter={{this.demoUpdateGenericFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-generic" @text="Generic" @type="generic" @onClear={{this.onClear}} as |FG|>
      <FG.Generic as |G|>
        <Hds::Form::TextInput::Field
          @value={{this.demoGenericName}}
          {{on "input" (fn this.onGenericNameChange G.updateFilter)}}
          name="name"
          as |FT|
        >
          <FT.Label>Name</FT.Label>
        </Hds::Form::TextInput::Field>
      </FG.Generic>
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoGenericFilters = {
  'demo-generic': {
    type: 'generic',
    text: 'Generic',
    dismissTagText: 'equals Name',
    data: {
      value: 'Name',
    },
  }
};

A generic filter can also contain multiple filters, similar to a multi-select filter. By passing an array of data to the data object each item in the array will be displayed as a distinct filter.

The dismissible filter tag will display the label for a given filter, and if the label is not provided it will display the value. The text can be customized by adding a dismissTagText value.


Generic: Name 1 Generic equals Name 2
<Hds::FilterBar @filters={{this.demoGenericArrayFilters}} @onFilter={{this.demoUpdateGenericArrayFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="demo-generic-array" @text="Generic" @type="generic" @onClear={{this.onClear}} as |FG|>
      <FG.Generic as |G|>
        <Hds::Form::TextInput::Field
          @value={{this.demoGenericArrayName1}}
          {{on "input" (fn this.onGenericArrayName1Change G.updateFilter)}}
          name="name-1"
          as |FT|
        >
          <FT.Label>Name 1</FT.Label>
        </Hds::Form::TextInput::Field>
        <Hds::Form::TextInput::Field
          @value={{this.demoGenericArrayName2}}
          {{on "input" (fn this.onGenericArrayName2Change G.updateFilter)}}
          name="name-2"
          as |FT|
        >
          <FT.Label>Name 2</FT.Label>
        </Hds::Form::TextInput::Field>
      </FG.Generic>
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoGenericArrayFilters = {
  'demo-generic-array': {
    type: 'generic',
    text: 'Generic',
    data: [
      { value: 'Name 1', label: 'Name 1' },
      { value: 'Name 2', dismissTagText: 'equals Name 2' }
    ]
  }
};

Callbacks

The @onClear argument can be added to the FilterGroup to listen for when a user triggers a clear of the filter group. This can be used to reset any inputs present in the filter content.

If your content for inputting filters can change dynamically, it's possible focus can be lost if an element with focus is removed. By default, the FiltersDropdown will close anytime focus leaves, including if it is lost. You can use the @onFocusOut argument to stop the dropdown from closing when this occurs and set focus on another appropriate element.

<Hds::FilterBar @filters={{this.demoGenericFilters}} @onFilter={{this.demoUpdateGenericFilters}} as |F|>
  <F.FiltersDropdown @onFocusOut={{this.onFocusOut}} as |D|>
    <D.FilterGroup @key="demo-generic" @text="Demo generic" @type="generic" @onClear={{this.onClear}} as |F|>
      <F.Generic as |G|>
        <Hds::Form::TextInput::Field
          @value={{this.name}}
          @id="demo-name"
          {{on "input" (fn this.onNameChange G.updateFilter)}}
          name="name"
          as |F|
        >
          <F.Label>Name</F.Label>
        </Hds::Form::TextInput::Field>
        {{#if this.showExtraName}}
          <Hds::Form::TextInput::Field
            @value={{this.nameExtra}}
            {{on "input" (fn this.onNameExtraChange G.updateFilter)}}
            name="name-extra"
            as |F|
          >
            <F.Label>Extra name</F.Label>
          </Hds::Form::TextInput::Field>
          <Hds::Button
            @text="Remove name"
            @color="secondary"
            @size="small"
            id="btn-remove-extra-name"
            {{on "click" this.removeExtraName}}
          />
        {{else}}
          <Hds::Button
            @text="Add name"
            @color="secondary"
            @size="small"
            id="btn-add-extra-name"
            {{on "click" this.addExtraName}}
          />
        {{/if}}
        <Hds::Text::Body @size="100">
          This filter has a dynamic template that changes based on the number of values added. On clear, the filter
          should reset to only showing one input.
        </Hds::Text::Body>
      </F.Generic>
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>

Search

The Filter Bar provides a search input, which can be used for searching across multiple areas of a data set. If the @hasSearch argument is set to true, a search input will be shown next to the dropdown.

When the search input's input event is triggered, a filter of type search will be included in the data object in the @onFilter callback.


Search: Lorem ipsum
<Hds::FilterBar
  @filters={{this.demoSearchFilters}}
  @onFilter={{this.demoUpdateSearchFilters}}
  @hasSearch={{true}}
  as |F|
>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>
// example of filter data
const demoSearchFilters = {
  'search': {
    type: 'search',
    text: 'Search',
    data: {
      value: 'Lorem ipsum',
    },
  }
};

The search input's placeholder text is "Search" by default, but can be customized with the @searchPlaceholder argument.

<Hds::FilterBar
  @filters={{this.demoEmptyFilters}}
  @onFilter={{this.demoUpdateEmptyFilters}}
  @hasSearch={{true}}
  @searchPlaceholder="Search projects"
  as |F|
>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
</Hds::FilterBar>

Bulk actions

The Filter Bar provides an ActionsDropdown contextual component that can be used for bulk actions to perform on a data set, or for other purposes. All contextual components from the Dropdown are yielded to the consumer except for the ToggleButton.

<Hds::FilterBar @filters={{this.demoEmptyFilters}} @onFilter={{this.demoUpdateEmptyFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
  <F.ActionsDropdown as |D|>
    <D.Interactive @icon="edit">Edit items</D.Interactive>
    <D.Interactive @icon="trash" @color="critical">Delete items</D.Interactive>
    <D.Separator />
    <D.Interactive @icon="check-circle">Select entire data set</D.Interactive>
    <D.Interactive @icon="rotate-ccw">Reset selection</D.Interactive>
  </F.ActionsDropdown>
</Hds::FilterBar>

The text of the ActionsDropdown defaults to "Actions", but can be customized with the @toggleButtonText argument. An icon can also be added with the @toggleButtonIcon argument.

<Hds::FilterBar @filters={{this.demoEmptyFilters}} @onFilter={{this.demoUpdateEmptyFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
  <F.ActionsDropdown @toggleButtonText="Item actions" @toggleButtonIcon="outline" as |D|>
    <D.Interactive @icon="edit">Edit items</D.Interactive>
    <D.Interactive @icon="trash" @color="critical">Delete items</D.Interactive>
    <D.Separator />
    <D.Interactive @icon="check-circle">Select entire data set</D.Interactive>
    <D.Interactive @icon="rotate-ccw">Reset selection</D.Interactive>
  </F.ActionsDropdown>
</Hds::FilterBar>

Generic content

For more customization of the functionality in the Filter Bar, an ActionsGeneric contextual component is provided that can be used to pass in any other content.

Generic content
<Hds::FilterBar @filters={{this.demoEmptyFilters}} @onFilter={{this.demoUpdateEmptyFilters}} as |F|>
  <F.FiltersDropdown as |D|>
    <D.FilterGroup @key="project" @text="Project" @type="multi-select" as |F|>
      <F.Checkbox @value="project-1" @label="Project 1" />
      <F.Checkbox @value="project-2" @label="Project 2" />
      <F.Checkbox @value="project-3" @label="Project 3" />
    </D.FilterGroup>
    <D.FilterGroup @key="version" @text="Version" @type="single-select" as |F|>
      <F.Radio @value="1.0" @label="1.0" />
      <F.Radio @value="2.0" @label="2.0" />
      <F.Radio @value="3.0" @label="3.0" />
    </D.FilterGroup>
  </F.FiltersDropdown>
  <F.ActionsGeneric>
    <Doc::Placeholder @height="24" @width="auto" @text="Generic content" @background="#e4e4e4" />
  </F.ActionsGeneric>
</Hds::FilterBar>

Component API

FilterBar

<[F].FiltersDropdown> yielded component
FilterBar::FiltersDropdown yielded as contextual component (see below).
<[F].ActionsGeneric> yielded component
FilterBar::ActionsGeneric yielded as contextual component (see below).
<[F].ActionsDropdown> yielded component
FilterBar::ActionsDropdown yielded as contextual component (see below).
filters object
Required
Object representing the currently applied filters. The shape is dependent upon the filter type (see below). It is required to set a string filter key for each entry. Ex: { 'my-filter-key': {...}}.
isLiveFilter boolean
  • false (default)
If true, the @onFilter callback is invoked immediately as filters are added in the dropdown (live updates). If false, changes in the dropdown are applied only when the user confirms via the "Apply filters" button, or clears with the "Clear all filters" button.

Note: The behavior of the search input is unaffected by this argument. The search filter is always applied after user submission via the change event.
hasSearch boolean
  • false (default)
When true, a search input is shown in the Filter Bar. Search input values are reported to the @onFilter callback as a filter with the key search.
searchPlaceholder string
  • "Search" (default)
Placeholder text for the search input when @hasSearch is true.
onFilter function
Callback invoked when filters are applied, changed, or cleared. Receives a single argument: the updated HdsFilterBarFilters object.
…attributes
This component supports use of ...attributes.

Filter types

The shape of the object for the @filters argument. The shape differs depending on the type provided.

type enum
Required
  • single-select
  • multi-select
  • numerical
  • date
  • time
  • datetime
  • generic
The type of data being filtered.
text string
The text of the filter group used in any applied filter tag labels.
data object | array
Required
The data of the applied filter. Each type requires its own shape of the data property. See below for details.
dismissTagText string
The text used in the applied filter tag that overrides any other text generated by the component. This should only be used if the type is equal to generic.

Single-select

The required structure of the data property when type is equal to single-select.

data object
Required
The data of the applied filter.
value string
Required
The value of the filter.
label string
The label of the applied filter, used in the applied filters tag. If empty, the value text will be used.

Multi-select

The required structure of the data property when type is equal to multi-select.

data array
Required
Array of the applied filters. Each item contains an object with the following properties:
value string
Required
The value of the filter.
label string
The label of the applied filter, used in the applied filters tag. If empty, the value text will be used.

Numerical

The required structure of the data property when type is equal to numerical.

data object
Required
The data of the applied filter.
selector enum
Required
  • less-than
  • less-than-or-equal-to
  • equal-to
  • greater-than-or-equal-to
  • greater-than
  • between
The comparison operator used in conjunction with the value to determine the range of numbers to filter on.
value number | object
Required
The value of the numerical filter. If the selector is between, the property is an object with the following properties
start number
The value of the minimum value for the between selector range of values.
end number
The value of the minimum value for the between selector range of values.

Date

The required structure of the data property when type is equal to date.

data object
Required
The data of the applied filter.
selector enum
Required
  • before
  • exactly
  • after
  • between
The comparison operator used in conjunction with the value to determine the range of dates to filter on.
value string | object
Required
The value of the date filter in the format YYYY-MM-DD. If the selector is between, the property is an object with the following properties
start string
The value of the start date for the between selector range of values in the format YYYY-MM-DD.
end string
The value of the end date for the between selector range of values in the format YYYY-MM-DD.

Time

The required structure of the data property when type is equal to time.

data object
Required
The data of the applied filter.
selector enum
Required
  • before
  • exactly
  • after
  • between
The comparison operator used in conjunction with the value to determine the range of times to filter on.
value string | object
Required
The value of the time filter in the format HH:MM in the 24hr format. If the selector is between, the property is an object with the following properties
start string
The value of the start date for the between selector range of values in the format HH:MM in 24hr format.
end string
The value of the end date for the between selector range of values in the format HH:MM in 24hr format.

Datetime

The required structure of the data property when type is equal to datetime.

data object
Required
The data of the applied filter.
selector enum
Required
  • before
  • exactly
  • after
  • between
The comparison operator used in conjunction with the value to determine the range of times to filter on.
value string | object
Required
The value of the date filter in the format {YYYY-MM-DD}T{HH:MM} where the time is in the 24hr format. If the selector is between, the property is an object with the following properties
start string
The value of the start date for the between selector range of values in the format {YYYY-MM-DD}T{HH:MM} where the time is in the 24hr format.
end string
The value of the end date for the between selector range of values in the format {YYYY-MM-DD}T{HH:MM} where the time is in the 24hr format.

Generic

The required structure of the data property when type is equal to generic.

data object | array
Required
The data of the applied filter. The follow properties can either be provided as one object or an array of objects.
value string
Required
The value of the filter.
label string
The label of the applied filter, used in the applied filters tag only if dismissTagText is not provided. If empty, the value text will be used.

FilterBar::FiltersDropdown

The FilterBar::FiltersDropdown is yielded as the [F].FiltersDropdown contextual component.

<[F].FilterGroup> yielded component
FilterBar::FilterGroup yielded as contextual component (see below).
height string
  • 600px (default)
If a @height parameter is provided then the tabs and tab panels will have a max-height. Can be any valid CSS height (px, rem, etc).
onFocusOut function
A callback function invoked when the dropdown menu loses focus, and focus does not move to another element (if provided).

Notice: Focus can be lost if content inside the dropdown is removed dynamically. This callback should be used to set focus to another element if this occurs. Without this callback the dropdown will close automatically when focus is lost.
…attributes
This component supports use of ...attributes.

FilterBar::FilterGroup

The FilterBar::FilterGroup is yielded as the [D].FilterGroup contextual component in the FilterBar::FiltersDropdown.

<[F].Checkbox> yielded component
FilterBar::FilterGroup::Checkbox yielded as contextual component (see below).
<[F].Radio> yielded component
FilterBar::FilterGroup::Radio yielded as contextual component (see below).
key string
Required
The key value used in the applied filters object for filters that are emitted for the given FilterGroup.
text string
Required
The text used for the given FilterGroup in the tabs of the FiltersDropdown, and in any applied filter tags for the group.
type enum
Required
  • single-select
  • multi-select
  • numerical
  • date
  • time
  • datetime
  • generic
The type of data being filtered.
searchEnabled boolean
  • false (default)
When true, a search input is shown in the filter group panel, which can be used to filter the list of available options. Note: This is only applicable to the single-select and multi-select filter types when used in conjunction with the Radio and Checkbox contextual components.

FilterBar::FilterGroup::Radio

The FilterBar::FilterGroup::Radio is yielded as the [F].Radio contextual component in the FilterBar::FilterGroup.

value string
Required
The value of the radio button.
label string
Required
The label of the radio button. It is also passed to the applied filter object on filter change.

FilterBar::FilterGroup::Checkbox

The FilterBar::FilterGroup::Checkbox is yielded as the [F].Checkbox contextual component in the FilterBar::FilterGroup.

value string
Required
The value of the checkbox button.
label string
Required
The label of the checkbox button. It is also passed to the applied filter object on filter change.

FilterBar::ActionsGeneric

The FilterBar::ActionsGeneric is yielded as the [F].ActionsGeneric contextual component.

yield
Elements passed as children are yielded as inner content of the component.
…attributes
This component supports use of ...attributes.

FilterBar::ActionsDropdown

Note: This component is an extension of the Dropdown component. All contextual components from the Dropdown are yielded to this component, except for the ToggleButton. View the Dropdown component API for more details on available contextual components. All properties are available on yielded contextual components. However, only the properties below are available for the Dropdown.

The FilterBar::ActionsDropdown is yielded as the [F].ActionsDropdown contextual component.

enableCollisionDetection boolean
  • false (default)
Setting it to true will automatically flip the list position to remain visible when near the edges of the viewport.
width string
any valid CSS width (px, rem, etc)
By default, the Dropdown List has a min-width of 200px and a max-width of 400px, so it adapts to the content size. If a @width parameter is provided then the list will have a fixed width.

We discourage the use of percentage values for this argument. The Dropdown list is a popover element, so relative units use document as a reference (not the parent element), meaning percentage values act similar to vw. If @matchToggleWidth is set, @width is overridden.
height string
any valid CSS height (px, rem, etc)
If a @height parameter is provided then the list will have a max-height.
preserveContentInDom boolean
  • false (default)
Controls if the content is always rendered in the DOM, even when the Dropdown is closed.
onClose function
Callback function invoked when the dropdown is closed (if provided).
onFocusOut function
A callback function invoked when the dropdown menu loses focus, and focus does not move to another element (if provided).

Notice: Focus can be lost if content inside the dropdown is removed dynamically. This callback should be used to set focus to another element if this occurs. Without this callback the dropdown will close automatically when focus is lost.
toggleButtonText text
  • "Actions" (default)
The text of the dropdown toggle button.
toggleButtonIcon string
Acceptable value: any icon name.
…attributes
This component supports use of ...attributes.

Anatomy

Filter Bar

Element Usage
Collapse/expand Required; Toggles display of the applied filters.
Filter toggle button Required; Toggles open and closed the Filter Dropdown.
Search Optional; Searches based on string matching across the entire data set.
Generic content Optional
Bulk actions Optional; Supports performing bulk actions on the data set.
Applied Filters List Required; Displays either the filters that have been applied to the data set, or an empty state if there are none.
Applied Filter Tag Required; Displays the filter as Parameter: Value within an HDS Tag.
Clear All Filters Required; Clears all of the applied filters and sets the Filter Bar and the data set back to their default state.

Filter Dropdown

The Filter Dropdown anatomy is dependent on the filter method:

  • Selection: multi-selection using checkboxes or single selection using radios.
  • Input: numerical, date, time, datetime values, or a range between a start and end value.

Element Usage
Parameters list Required; Displays all of the available filter parameters, generally corresponding with columns in a table.
Filter value(s) Required; Displays available values within a parameter for selection, or allows the input of custom values.
Apply Filters action Required if the filtering method is "per-filter". Applies the filters selected in either the values list or the values input.
Clear all filters action Required; Clears the selection of filters across all parameters.
Selected filters count Displays the number of values selected in a parameter.

Filter value selection

This filter value selection anatomy is the same for single selection using radios.

Element Usage
Search Optional; Searches across available filter parameter values using string matching.
Clear selected values action Required; De-selects all values in the list.
Value input Required; Supports filtering on numbers, strings, dates, or times.

Filter value input

Element Usage
Operator selection Required; Allows the user to select how the filter is applied.
Value input Required; Allows the user to input a value to filter upon such as a number, string, date, or time.
Clear filter Required; Clears the filter operator and input fields.

Filter value range input

When applying a filter value via an input, if Between is selected in the operator list, the input fields will be broken into a start value and an end value.

Element Usage
Operator selection Required; Allows the user to select how the filter is applied.
Value range input Required; Allows the user to input start and end values to filter upon.
Clear filter fields action Required; Clears the filter input field.

Custom filtering

The Filter Dropdown supports custom filtering by passing elements to a generic yielded block.

Value input operators

Available operators are dependent on the type of data being filtered upon, but are generally either numerical, or date/time based.

Type Options
Numerical Less than (>), Less than or equal to (≤), Equal to (=), Not equal to (≠), Greater than or equal to (≥), Greater than (>), Between
Date and time Before, Exactly, After, Between

States

Parameter List Item

Conformance Rating

Conformant

When used as recommended, there should not be any WCAG conformance issues with this component. Consumers are responsible for the conformance of any content in a block yield.

Keyboard navigation

Accessing the dropdown menu

Tab

Focus on the dropdown toggle button.

Filter bar with focus on the dropdown toggle button

Spacebar
Enter

Open the dropdown menu.

Filter bar with the dropdown opened

Tab

Focus on the selected tab.

Filter bar with the dropdown opened and the selected tab focused

Left arrow
Right arrow
Up arrow
Down arrow

Move between tabs.

Filter bar with the dropdown opened and the focus moved to the second tab

Spacebar
Enter

Select a tab.

Filter bar with the dropdown opened and the second tab selected

Tab

Move to the selected tab content.

Filter bar with the dropdown opened and the focus inside the second tab panel

Esc

Close the dropdown.

Filter bar with the dropdown closed and focus on the dropdown toggle button

Tab

Focus the search input.

Filter bar with focus on the search input

[a-z]

Enter a search term into the input.

Filter bar with search input containing "lorem ipsum" value

Enter

Execute the search.

Filter bar with a new filter added for "Search: lorem ipsum"

Applicable WCAG Success Criteria

This section is for reference only. This component intends to conform to the following WCAG Success Criteria:

  • 1.3.1 Info and Relationships (Level A):
    Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text.
  • 1.3.2 Meaningful Sequence (Level A):
    When the sequence in which content is presented affects its meaning, a correct reading sequence can be programmatically determined.
  • 1.3.5 Identify Input Purpose (Level AA):
    The purpose of each input field collecting information about the user can be programmatically determined when the input field serves a purpose identified in the Input Purposes for User Interface Components section; and the content is implemented using technologies with support for identifying the expected meaning for form input data.
  • 1.4.1 Use of Color (Level A):
    Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element.
  • 1.4.10 Reflow (Level AA):
    Content can be presented without loss of information or functionality, and without requiring scrolling in two dimensions.
  • 1.4.11 Non-text Contrast (Level AA):
    The visual presentation of the following have a contrast ratio of at least 3:1 against adjacent color(s): user interface components; graphical objects.
  • 1.4.12 Text Spacing (Level AA):
    No loss of content or functionality occurs by setting all of the following and by changing no other style property: line height set to 1.5; spacing following paragraphs set to at least 2x the font size; letter-spacing set at least 0.12x of the font size, word spacing set to at least 0.16 times the font size.
  • 1.4.3 Minimum Contrast (Level AA):
    The visual presentation of text and images of text has a contrast ratio of at least 4.5:1
  • 1.4.4 Resize Text (Level AA):
    Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality.
  • 2.1.1 Keyboard (Level A):
    All functionality of the content is operable through a keyboard interface.
  • 2.1.2 No Keyboard Trap (Level A):
    If keyboard focus can be moved to a component of the page using a keyboard interface, then focus can be moved away from that component using only a keyboard interface.
  • 2.4.3 Focus Order (Level A):
    If a Web page can be navigated sequentially and the navigation sequences affect meaning or operation, focusable components receive focus in an order that preserves meaning and operability.
  • 2.4.7 Focus Visible (Level AA):
    Any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible.
  • 3.2.1 On Focus (Level A):
    When any user interface component receives focus, it does not initiate a change of context.
  • 3.2.2 On Input (Level A):
    Changing the setting of any user interface component does not automatically cause a change of context unless the user has been advised of the behavior before using the component.
  • 3.3.2 Labels or Instructions (Level A):
    Labels or instructions are provided when content requires user input.
  • 4.1.2 Name, Role, Value (Level A):
    For all user interface components, the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies.

Support

If any accessibility issues have been found within this component, let us know by submitting an issue.

6.1.0

Added support for an array of values for the generic filter type data

Added @onClear argument to FilterGroup contextual component

Added @onFocusOut argument to the FiltersDropdown to help manage focus for dynamic dropdown content and prevent the dropdown from closing when content changes

Converted component to gts format.

6.0.0

Added FilterBar component and related sub-components


Related