# 分类徽章样式

**URL:** https://meta.discourse.org/t/category-badge-styles/285320
**Category:** Theme component
**Tags:** official, category-badge-styles
**Created:** [2023年十一月13日 13:40 UTC](https://meta.discourse.org/t/category-badge-styles/285320 "2023-11-13T13:40:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [2023年十一月13日 13:40 UTC](https://meta.discourse.org/t/category-badge-styles/285320/1 "2023-11-13T13:40:12Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **摘要** | **类别徽章样式** 已取代已弃用的 `category_style` 管理设置的功能 |
| 👓 | **预览** | [在 Discourse 主题创建器中预览](https://discourse.theme-creator.io/theme/Discourse/category-badge-style-box)（方框）  
[在 Discourse 主题创建器中预览](https://discourse.theme-creator.io/theme/Discourse/category-badge-style-bar)（条形） |
| 🛠 | **代码仓库** | [https://github.com/discourse/discourse-category-badge-styles](https://github.com/discourse/discourse-category-badge-styles) |
| ❓ | **安装指南** | [如何安装主题或主题组件](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682) |

安装此主题组件

> [@](#):
>
> :discourse2: 由于这是由 Discourse 团队维护的 #official 主题组件，因此可以在 Meta 相应的分类中提出 #support、#contribute:bug、#Contribute > UX 和 #Contribute > Feature 请求，并打上相应的主题组件标签。点击下方链接即可开始。👍
> 
> [❓&nbsp; **支持**](https://meta.discourse.org/new-topic?category_id=6&tags=category-badge-styles "请求关于配置和使用类别徽章样式的帮助") [🐛&nbsp; **错误**](https://meta.discourse.org/new-topic?category_id=1&tags=category-badge-styles "错误报告意味着某些功能已损坏，导致无法正常使用主题组件") [👀&nbsp; **用户体验**](https://meta.discourse.org/new-topic?category_id=9&tags=category-badge-styles "关于类别徽章样式用户界面的讨论，以及功能如何呈现（包括语言和界面元素）") [💡&nbsp; **功能**](https://meta.discourse.org/new-topic?category_id=2&tags=category-badge-styles "讨论如何改进或增强现有的类别徽章样式功能，以及提议的新功能如何运作")

### 功能特性

随着 `category_style` 管理设置的变更，将类别徽章样式设置为方框、条形或无的功能已移至此主题组件。您可以在此处阅读有关该变更的更多信息：

> [@切换到单一类别风格的站点设置](https://meta.discourse.org/t/moving-to-a-single-category-style-site-setting/282441):
>
> information_source Discourse 更新于 2023-11-13T05:00:00Z (UTC) 或之后将包含此更改。 为了统一用户界面中类别的样式（例如在侧边栏中，或在聊天或帖子中提及类别时），我们将从 category\_style 站点设置中移除非默认的类别样式，并最终完全移除此设置。 information_source 对于已经在使用默认（项目符号）类别样式的用户，无需采取任何操作。 对于正在使用非默认（项目符号）类别以外的用户，我们有一个新的[主题组件](https://github.com/discourse/discourse-category-badge-styles)，您可以立即安全地安装。通过这样做，即使我们最终在 3.2 正式版发布之前移除此核心设置，您的站点也将继续使用您现有的类别样式设置。 如果您不特别喜欢非默认的类别样式，我们鼓励您切换回默认（项目符号）样式，以避免在您的站点上需要额外的 \<$\>主题组件\</\>。方法如下： 无需安装任何内容即可切换回默认的项目符号样式。 查找 category\_style 管理员设置，并将其更改为“bullet”，使其看起来像这样：

### 示例

 ![类别徽章 - 条形](https://global.discourse-cdn.com/meta/original/4X/f/8/e/f8e77d1751c03acc1ce19907f46e26f77813e80f.png)

 ![类别徽章 - 方框](https://global.discourse-cdn.com/meta/original/4X/d/c/3/dc34147f7bf46177aa506d4f2b67a6018257e3b3.png)

 ![类别徽章 - 无](https://global.discourse-cdn.com/meta/original/4X/0/d/2/0d2be29e9e1c8ea9fa22c86823df6b5840646518.png)

### 设置

仅此一项简单设置：

| 名称 | 描述 |
| --- | --- |
| 类别徽章样式 | 类别徽章的期望样式 |

  

> :discourse2: **由我们托管？** 主题组件可在我们的标准版、商业版和企业版计划中使用。

---

<div class="post-metadata">

### Author: ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)
#### Post date: [2023年十二月24日 18:52 UTC](https://meta.discourse.org/t/category-badge-styles/285320/2 "2023-12-24T18:52:36Z")

</div>

刚切换到这个，大部分样式都恢复了，但是否可以在 style 属性中添加 `#color: FOREGROUND-COLOUR` 呢？

所以这样：

```plaintext
Style Attribute {
--category-badge-color: #0;
--category-badge-text-color: #865ac9;
}

```

会变成这样：

```plaintext
Style Attribute {
--category-badge-color: #0;
--category-badge-text-color: #865ac9;
color: #865ac9;
}

```

然后变成这样：

 ![Screenshot 2023-12-24 at 18.44.10](https://global.discourse-cdn.com/meta/original/4X/4/3/e/43e03d706c0de7abb89216ecb959ae6403fc2ae0.png)

（或者我可以在本地安装上自己完成这个操作吗？）

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2025年四月18日 18:24 UTC](https://meta.discourse.org/t/category-badge-styles/285320/3 "2025-04-18T18:24:35Z")

</div>

只是另一个友好的提醒，但如果此组件正在使用中，并且徽章样式为空，它将隐藏所有新的样式类别图标。
