Tag
分类标签或筛选芯片,是 Chip 的别名。
DefaultOutlineFilledRemovable
导入
“导入”部分import { Tag } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。复制到 src/components/ 即可开始使用。
import { Stack, Tag } from "@pelagornis/page/components";
export default function TagDemo() { return ( <Stack direction="row" gap="sizeSmall" wrap> <Tag variant="default">Default</Tag> <Tag variant="outline">Outline</Tag> <Tag variant="filled">Filled</Tag> <Tag onRemove={() => {}}>Removable</Tag> </Stack> );}在 MDX 中使用
“在 MDX 中使用”部分Tag 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。
---title: Example---
import { Tag } from "@pelagornis/page/components";
<Tag variant="outline">Draft</Tag><Tag variant="filled">Published</Tag>在 Markdoc 中使用
“在 Markdoc 中使用”部分pageMarkdoc() 会注册该组件的 tag 标签。在 markdoc.config.mjs 中添加一次预设(见 在 Markdoc 中使用),即可在任意 .mdoc 页面中使用。
{% tag variant="outline" %}Draft{% /tag %}{% tag variant="filled" %}Published{% /tag %}属性名和值与 React props 相同。
变体
“变体”部分各 variant prop 可接受的值。
| Prop | 取值 |
|---|---|
variant | default outline filled |
size | sm md lg |
结构
“结构”部分组件各部分及其渲染的 data-refineui 角色。
| 部件 | 角色 |
|---|---|
root | chip |
remove | chip-remove |
状态
“状态”部分组件会样式化的状态。组件状态通过 data 属性暴露。
| 类型 | 状态 |
|---|---|
| 伪类 | focus-visible |
键盘
“键盘”部分组件获得焦点时处理的按键。
| 按键 | 动作 |
|---|---|
| Enter | activate |
| Space | activate |
参考
“参考”部分- 设计指南与令牌细节见 RefineUI · Tag。
- 通用规则见 在 MDX 中使用 与 在 Markdoc 中使用。