---
title: "useCategory"
description: "useCategory 管理文档侧边栏的分类配置系统，通过 categories 属性定义各分类的显示标题和排序规则，将组件或 Composable 文档按功能分组展示。在 app/composables/useCategory.ts 中覆盖实现即可自定义分类配置。"
seo_title: "useCategory"
seo_description: "Organize Movk Nuxt Docs sidebar sections with useCategory, category titles, ordering rules, and project-level category overrides."
canonical_url: "https://docs.mhaibaraai.cn/docs/composables/use-category"
---
# useCategory

> useCategory 管理文档侧边栏的分类配置系统，通过 categories 属性定义各分类的显示标题和排序规则，将组件或 Composable 文档按功能分组展示。在 app/composables/useCategory.ts 中覆盖实现即可自定义分类配置。

## 概述

管理文档的分类系统，方便对文档进行分组和导航。

### 配置分类

在项目中创建 `composables/useCategory.ts` 覆盖默认配置：

```ts
export function useCategory() {
  return {
    categories: {
      components: [
        {
          id: 'content',
          title: 'Content Components',
          icon: 'i-lucide-component'
        },
        {
          id: 'layout',
          title: 'Layout Components',
          icon: 'i-lucide-layout-dashboard'
        }
      ],
      composables: [
        {
          id: 'navigation',
          title: 'Navigation',
          icon: 'i-lucide-compass'
        },
        {
          id: 'ui',
          title: 'UI Utilities',
          icon: 'i-lucide-sparkles'
        }
      ]
    }
  }
}
```

### Frontmatter 中使用分类

```md
---
title: ComponentPropsLinks
category: content
---
```

## API

### `useCategory()`

返回分类配置。

### 返回值

**categories** (`Record<string, Category[]>`): 分类配置对象，键为文档目录 slug。分类 ID，对应 frontmatter 的 category 字段。分类显示标题。分类图标类名。

## Changelog

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


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
