---
title: "useDocsFilterConfig"
description: "Config, visibility check and filter function behind the sidebar navigation filter, mapped to aside.filter in app.config. Use them in a custom sidebar top or sidebar body component to keep the default filtering behavior."
canonical_url: "https://docs.mhaibaraai.cn/en/docs/reference/composables/use-docs-filter-config"
---
# useDocsFilterConfig

> Config, visibility check and filter function behind the sidebar navigation filter, mapped to aside.filter in app.config. Use them in a custom sidebar top or sidebar body component to keep the default filtering behavior.

The sidebar filter is built from three exports of `useDocsFilterConfig.ts`: `useDocsFilterConfig` reads the config, `useDocsFilterVisible` decides whether the input is shown, and `filterNavigation` filters the groups. The search term is shared by the docs layout through `provide('docsFilterSearch', ref(''))` and cleared on route change.

## Usage

Enable the filter:

```ts [app/app.config.ts]
export default defineAppConfig({
  aside: {
    filter: {
      enabled: true,
      threshold: 10,
      shortcut: '/'
    }
  }
})
```

Read the config in a custom `DocsAsideLeftTop`:

```vue [app/components/DocsAsideLeftTop.vue]
<script setup lang="ts">
const searchTerm = inject<Ref<string>>('docsFilterSearch', ref(''), false)
const { placeholder } = useDocsFilterConfig()
</script>

<template>
  <UInput v-model="searchTerm" :placeholder="placeholder" />
</template>
```

## Signature

```ts
function useDocsFilterConfig(): {
  enabled: ComputedRef<boolean>
  placeholder: ComputedRef<string>
  threshold: ComputedRef<number>
  shortcut: ComputedRef<string>
}

function useDocsFilterVisible(): ComputedRef<boolean>

function filterNavigation(
  groups: ContentNavigationItem[],
  term: string,
  scoreItem: (item: ContentNavigationItem, term: string, fields: string[]) => unknown
): ContentNavigationItem[]
```

## Return Value

`useDocsFilterConfig()`:

| Name | Type | Description |
| --- | --- | --- |
| `enabled` | `ComputedRef<boolean>` | `aside.filter.enabled`, default `false` |
| `placeholder` | `ComputedRef<string>` | `aside.filter.placeholder`; falls back to the built-in translation `docs.filterPlaceholder` |
| `threshold` | `ComputedRef<number>` | `aside.filter.threshold`, default `10` |
| `shortcut` | `ComputedRef<string>` | `aside.filter.shortcut`, default `/`; an empty string binds no shortcut |

`useDocsFilterVisible()` returns a `ComputedRef<boolean>` that is `true` when the filter is enabled and the groups of the current section contain at least `threshold` pages in total.

`filterNavigation()` returns the filtered groups: with an empty `term` the groups are returned unchanged; otherwise pages are matched on `title` and `description`, parents of matching children are kept, and groups without matches are removed. `scoreItem` usually comes from Nuxt UI's `useFilter()`:

```ts
import { useFilter } from '@nuxt/ui/composables'

const { scoreItem } = useFilter()
const filtered = computed(() => filterNavigation(navigationByCategory.value, searchTerm.value, scoreItem))
```

## Related

- [app.config Reference](https://docs.mhaibaraai.cn/en/docs/reference/app-config)
- [useNavigation](https://docs.mhaibaraai.cn/en/docs/reference/composables/use-navigation)

## Changelog

See commit history for [layer/app/composables/useDocsFilterConfig.ts](https://github.com/mhaibaraai/movk-nuxt-docs/commits/main/layer/app/composables/useDocsFilterConfig.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-nuxt-docs/blob/main/layer/app/composables/useDocsFilterConfig.ts)


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.cn/sitemap.md) for all pages.
