Icon
通过 WebIcon 从图标字体渲染的 RefineUI 系统图标。
导入
“导入”部分import { WebIcon } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。
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> );}在 MDX 中使用
“在 MDX 中使用”部分Icon 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。
---title: Example---
import { WebIcon } from "@pelagornis/page/components";
<WebIcon name="search" size={24} aria-label="Search" />在 Markdoc 中使用
“在 Markdoc 中使用”部分pageMarkdoc() 会为这个组件注册 icon 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。
{% icon name="search" size=24 ariaLabel="Search" /%}属性的名称和取值与 React props 相同。
参考
“参考”部分- 通用规则见在 MDX 中使用和在 Markdoc 中使用。