跳转到内容
Page

Icon

通过 WebIcon 从图标字体渲染的 RefineUI 系统图标。

󰕈󰘕󰁰󰁳󰒔󰯱󰈯
import { WebIcon } from "@pelagornis/page/components";

上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。

src/components/IconExample.tsx
import { Stack, WebIcon } from "@pelagornis/page/components";
const icons = ["search", "add", "settings", "home", "document", "chevron_right"];
export default function IconDemo() {
return (
<Stack direction="row" gap="sizeLarge" align="center" wrap>
{icons.map((name) => (
<WebIcon key={name} name={name} size={24} color="currentColor" aria-label={name} />
))}
<WebIcon name="heart" size={24} iconStyle="filled" color="currentColor" aria-label="heart filled" />
</Stack>
);
}

Icon 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。

src/content/docs/example.mdx
---
title: Example
---
import { WebIcon } from "@pelagornis/page/components";
<WebIcon name="search" size={24} aria-label="Search" />

pageMarkdoc() 会为这个组件注册 icon 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。

src/content/docs/example.mdoc
{% icon name="search" size=24 ariaLabel="Search" /%}

属性的名称和取值与 React props 相同。