Dashboard filters are available through Forge's Early Access Program (EAP). To request access, submit the dashboard filters module EAP form.
EAP features are offered to selected users for testing and feedback purposes. They are unsupported and subject to change without notice.
Hook for accessing the filter represented by the currently open dropdown and its session-only override.
For module configuration and setup instructions, see Dashboard filter (EAP).
Install Forge hooks using the @forge/hooks npm package.
Import @forge/hooks using a bundler, such as Webpack.
To add the useCurrentFilter hook to your app:
1 2import { useCurrentFilter } from "@forge/hooks/dashboards";
Here is an example of accessing the currently open filter and override:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20import React from "react"; import { useCurrentFilter } from "@forge/hooks/dashboards"; function CurrentFilter() { const { filter, override } = useCurrentFilter(); if (!filter) { return null; } const filterLabel = "label" in filter ? filter.label : filter.id; return ( <div> <p>Filter: {filterLabel}</p> <p>Selected values: {override?.values?.join(", ") ?? "None"}</p> </div> ); }
1 2 3 4 5 6 7function useCurrentFilter(): UseCurrentFilterResult; interface UseCurrentFilterResult { filter: FilterExpression | null; override: FilterOverride | null; }
For the FilterExpression and FilterOverride types, see the filter model.
null when no filter dropdown is open.null when no override exists.Rate this page: