Skip to content

Filter

Set of select menus used for filtering items.

Set of select menus used for filtering items. Uses Mixitup. if additional settings are needed for a custom filter, add data-mix-type with a custom value, and add the corresponding functionality to the switch statement in /src/scripts/components/filter.js

Filter Container

In addition to the filter component include, you will also need a div with a class of mixitup and some optional HTML attributes that map to config options when Mixitup is instantiated. Each item in your list to filter needs a class of mix plus any additional classes that match the filter controls. Check out the mixitup documentation for more information.

  • data-mix-scope: Can be either global or local. Defaults to local, which means it will only look inside the mix container for controls.
  • data-mix-counter: id of another HTML element on the page to be updated with the current total of matching mix items on each filter action.
  • data-mix-counter-label: description of items to be used in the counter. Defaults to 'result'.
  • data-mix-per-page: Number of items to show per page. If ommitted, pagination will be disabled.
  • data-mix-pager: id of a ul tag on the page to act as the container for the pagination controls mixitup generates.
  • data-mix-type: Used for initial filtering and other customizations. Refer to src/scripts/components/filter.js for more details and available options.
  • data-placeholder: id of another HTML element on the page to be shown when no items match the current filter.

Specifications

Properties

PropertyTypeDescriptionRequiredDefault
attributesarray List of dimensions with with options for each oneYes-
└ itemobject ---
└ namestring Unique filter-group name for mixitup's multi-dimensional filtering--
└ labelstring Name of this attribute--
└ default_valuestring Value for first option in list--
└ defaultstring Label for first option in list--
└ typestring Control to render

Allowed Values: "accordion", "select"
-"select"
└ optionsarray|object By default an array of options is passed in. If an object is provided instead with a key of _optgroups set to true, the filter will use an array of arrays in the groups key--
└ itemobject If array, individual option item--
└ valuestring ---
└ labelstring ---
└ _optgroupsboolean Flag to enable grouping of options--
└ groupsobject Key names are used as optgroup labels, values are arrays of key/value pairs for the action option elements--
└ [additionalProperties]string ---
enable_searchboolean Option to enable search field. Searches data-title attribute on mix itemsNofalse
enable_statusboolean Option to enable section for current filter terms / clear buttonsNofalse
enable_resetboolean Show a reset button to clear filterNofalse

Changelog

6.12.1 (2024-06-12)

  • fix: set correct prefixes for space vars for color system v2 (f023a65)

6.12.1 (2024-06-12)

  • fix: set correct prefixes for space vars for color system v2 (f023a65)

6.5.0 (2023-12-13)

  • fix: correctly set size of close buttons in status (#521) (a71d793)
  • fix: enable status bar outside of program-specific setting (cb997c7)
  • fix: only sort for "program-specific" (5d315da)

3.2.0 (2023-04-03)

  • fix: adjust layout of faq results counter (#396) (dd357fd)
  • fix: adjust spacing of search activity icon in (#398) (369de25)

1.32.0 (2022-04-26)

  • feat: support optgroups in attribute options (e79510f)

1.27.0 (2021-12-10)

  • fix: add check for vertical filter element (120e485)
  • fix: support 0 or more accordion filters (b65171c)

1.24.0 (2021-09-15)

  • fix: fix bug where results were changing order (#141) (9ade4e2)
  • feat: added filter by url query parameters (#142) (9802261)

1.23.0 (2021-08-04)

  • fix: added filter types to components page (#134) (6c3bdaf)
  • fix: only apply sticky if 10 or less options (635f256)
  • fix: only apply sticky style on screens tall enough (f87eb9a)

1.20.1 (2021-06-02)

  • fix: add correct spacing to heading (0cf3a9e)

1.19.1 (2021-05-04)

  • fix: remove fixed height set on md and up (#91) (83d600a)

1.18.0 (2021-04-01)

  • fix: scroll up on page change, reset page on filter update, style active page (#60) (ef6af3e)

1.5.0 (2020-06-23)

  • feat: add option for status/reset buttons (db0d98e)

1.2.0 (2020-04-17)

  • fix: update select styling (4d79695)
  • feat: add boxed style variation (4adfe51)
  • feat: add search option (db38533)
  • feat: support counters, pagination, scope per instance (b17472d)

1.1.0

  • filter added

Contains

Other core components embedded within this template.

Contained In

Other components that use this component (not including freeform content slots).

Examples

Filter

Vehicula

Category 1

Tag A

Consectetur

Category 2

Tag A

Vulputate

Category 3

Tag B

Sem Magna

Category 2

Tag B

Ligula

Category 3

Tag B

Ligula

Category 1

Tag C

<div class="mixitup" data-placeholder="unique-id-no-items">
	{{ include( 'components/filter.twig', {
		attributes: [
			{
				name: 'category',
				label: 'Category',
				default: 'Select Category',
				options: [
					{
						value: 'category-1',
						label: 'Category 1'
					},
					{
						value: 'category-2',
						label: 'Category 2'
					},
					{
						value: 'category-3',
						label: 'Category 3'
					}
				],
			},
			{
				name: 'tag',
				label: 'Tag',
				default: 'Select Tag',
				options: [
					{
						value: 'tag-a',
						label: 'Tag A'
					},
					{
						value: 'tag-b',
						label: 'Tag B'
					},
					{
						value: 'tag-c',
						label: 'Tag C'
					}
				],
			}
		]
	} ) }}
	<div class="tux-c-filter-placeholder" id="unique-id-no-items" style="display: none;">
		<p>No programs were found matching the selected filters.</p>
	</div>
	<div class="tux-l-card-grid">
		<x-card class="mix category-1 tag-a">
			<x-slot name="header">
				<h2 class="h4">Vehicula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-a">
			<x-slot name="header">
				<h2 class="h4">Consectetur</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-b">
			<x-slot name="header">
				<h2 class="h4">Vulputate</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-b">
			<x-slot name="header">
				<h2 class="h4">Sem Magna</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-a">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-1 tag-c">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag C</p>
			</x-slot>
		</x-card>
	</div>
</div>

Vertical Filter

Vehicula

Category 1

Tag A

Consectetur

Category 2

Tag A

Vulputate

Category 3

Tag B

Sem Magna

Category 2

Tag B

Ligula

Category 3

Tag B

Ligula

Category 1

Tag C

<div class="mixitup" data-placeholder="unique-id-no-items">
	{{ include( 'components/filter.twig', {
		class: 'tux-c-filter--vertical',
		attributes: [
			{
				name: 'category',
				label: 'Category',
				default: 'Select Category',
				options: [
					{
						value: 'category-1',
						label: 'Category 1'
					},
					{
						value: 'category-2',
						label: 'Category 2'
					},
					{
						value: 'category-3',
						label: 'Category 3'
					}
				],
			},
			{
				name: 'tag',
				label: 'Tag',
				default: 'Select Tag',
				options: [
					{
						value: 'tag-a',
						label: 'Tag A'
					},
					{
						value: 'tag-b',
						label: 'Tag B'
					},
					{
						value: 'tag-c',
						label: 'Tag C'
					}
				],
			}
		]
	} ) }}
	<div class="tux-c-filter-placeholder" id="unique-id-no-items" style="display: none;">
		<p>No programs were found matching the selected filters.</p>
	</div>
	<div class="tux-l-card-grid">
		<x-card class="mix category-1 tag-a">
			<x-slot name="header">
				<h2 class="h4">Vehicula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-a">
			<x-slot name="header">
				<h2 class="h4">Consectetur</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-b">
			<x-slot name="header">
				<h2 class="h4">Vulputate</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-b">
			<x-slot name="header">
				<h2 class="h4">Sem Magna</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-a">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-1 tag-c">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag C</p>
			</x-slot>
		</x-card>
	</div>
</div>

Accordion Filter

Vehicula

Category 1

Tag A

Consectetur

Category 2

Tag A

Vulputate

Category 3

Tag B

Sem Magna

Category 2

Tag B

Ligula

Category 3

Tag B

Ligula

Category 1

Tag C

<div class="mixitup" data-placeholder="unique-id-no-items">
	{{ include( 'components/filter.twig', {
		class: 'tux-c-filter--vertical',
		attributes: [
			{
				name: 'category',
				label: 'Category',
				default: 'Select Category',
				type: 'accordion_filter',
				options: [
					{
						value: 'category-1',
						label: 'Category 1'
					},
					{
						value: 'category-2',
						label: 'Category 2'
					},
					{
						value: 'category-3',
						label: 'Category 3'
					}
				],
			},
			{
				name: 'tag',
				label: 'Tag',
				default: 'Select Tag',
				type: 'accordion_filter',
				options: [
					{
						value: 'tag-a',
						label: 'Tag A'
					},
					{
						value: 'tag-b',
						label: 'Tag B'
					},
					{
						value: 'tag-c',
						label: 'Tag C'
					}
				],
			}
		]
	} ) }}
	<div class="tux-c-filter-placeholder" id="unique-id-no-items" style="display: none;">
		<p>No programs were found matching the selected filters.</p>
	</div>
	<div class="tux-l-card-grid">
		<x-card class="mix category-1 tag-a">
			<x-slot name="header">
				<h2 class="h4">Vehicula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-a">
			<x-slot name="header">
				<h2 class="h4">Consectetur</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag A</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-b">
			<x-slot name="header">
				<h2 class="h4">Vulputate</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-2 tag-b">
			<x-slot name="header">
				<h2 class="h4">Sem Magna</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 2</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-3 tag-a">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 3</p>
				<p>Tag B</p>
			</x-slot>
		</x-card>
		<x-card class="mix category-1 tag-c">
			<x-slot name="header">
				<h2 class="h4">Ligula</h2>
			</x-slot>
			<x-slot name="content">
				<p>Category 1</p>
				<p>Tag C</p>
			</x-slot>
		</x-card>
	</div>
</div>