CodeHighlighter代码高亮
CodeHighlighter
代码高亮
用于高亮代码格式。
使用import { CodeHighlighter } from "@ant-design/x"; |
文档 |
版本自 2.1.0 起支持 |
使用import { CodeHighlighter } from "@ant-design/x"; |
文档 |
版本自 2.1.0 起支持 |
CodeHighlighter 组件用于需要展示带有语法高亮的代码片段的场景。
通用属性参考:通用属性。
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| lang | 语言 | string | - |
| children | 代码内容 | string | - |
| header | 顶部 | React.ReactNode | null | React.ReactNode |
| className | 样式类名 | string | |
| classNames | 样式类名 | string | - |
| highlightProps | 代码高亮配置 | highlightProps | - |
| 属性 | 说明 | 类型 | 版本 |
|---|---|---|---|
| nativeElement | 获取原生节点 | HTMLElement | - |
| Token 名称 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| colorBgTitle | 标题背景颜色 | string | rgba(0,0,0,0.06) |
| colorBorderCode | 代码块边框颜色 | string | #f0f0f0 |
| colorTextTitle | 标题文本颜色 | string | rgba(0,0,0,0.88) |
import React from 'react';
import { Button } from 'antd';
const App = () => (
<div>
<Button type="primary">Primary Button</Button>
</div>
);
export default App;.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>当前计数:{count}</p>
<button onClick={() => setCount(count + 1)}>增加</button>
</div>
);
}import React from 'react';
import { XMarkdown } from '@ant-design/x-markdown';
const App = () => <XMarkdown content='Hello World' />;
export default App;