mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
882cec62d6
* docs: Add components overview page * fix detail * remove ContributorsList form overview page * fix components url * improve code style * remove extra file * fix detail * fix lint * fix lint * docs: Finish components overview page * fix lint * docs: Update cover * fix lint * update cover * update menu * improve overview page * refactor code * fix order * update title * add components count * fix overview page ssr bug * move less file * update title margin Co-authored-by: arvinxx <arvinx@foxmail.com>
74 lines
3.7 KiB
Markdown
74 lines
3.7 KiB
Markdown
---
|
|
category: Components
|
|
subtitle: 排版
|
|
type: 通用
|
|
title: Typography
|
|
cols: 1
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
|
|
---
|
|
|
|
文本的基本格式。
|
|
|
|
## 何时使用
|
|
|
|
- 当需要展示标题、段落、列表内容时使用,如文章/博客/日志的文本样式。
|
|
- 当需要一列基于文本的基础操作时,如拷贝/省略/可编辑。
|
|
|
|
## API
|
|
|
|
### Typography.Text
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
| --- | --- | --- | --- | --- |
|
|
| code | 添加代码样式 | boolean | false | |
|
|
| copyable | 是否可拷贝,为对象时可设置复制文本以回调函数 | boolean \| { text: string, onCopy: Function } | false | |
|
|
| delete | 添加删除线样式 | boolean | false | |
|
|
| disabled | 禁用文本 | boolean | false | |
|
|
| editable | 是否可编辑,为对象时可对编辑进行控制 | boolean \| { editing: boolean, onStart: Function, onChange: Function(string) } | false | |
|
|
| ellipsis | 设置自动溢出省略,需要设置元素宽度 | boolean | false | |
|
|
| mark | 添加标记样式 | boolean | false | |
|
|
| keyboard | 添加键盘样式 | boolean | false | 4.3.0 |
|
|
| underline | 添加下划线样式 | boolean | false | |
|
|
| strong | 是否加粗 | boolean | false | |
|
|
| type | 文本类型 | `secondary` \| `warning` \| `danger` | - | |
|
|
|
|
### Typography.Title
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
| --- | --- | --- | --- | --- |
|
|
| copyable | 是否可拷贝,为对象时可设置复制文本以回调函数 | boolean \| { text: string, onCopy: Function } | false | |
|
|
| delete | 添加删除线样式 | boolean | false | |
|
|
| disabled | 禁用文本 | boolean | false | |
|
|
| editable | 是否可编辑,为对象时可对编辑进行控制 | boolean \| { editing: boolean, onStart: Function, onChange: Function(string) } | false | |
|
|
| ellipsis | 自动溢出省略,为对象时可设置省略行数与是否可展开等 | boolean \| { rows: number, expandable: boolean, onExpand: Function(event), onEllipsis: Function(ellipsis) } | false | onEllipsis: 4.2.0 |
|
|
| level | 重要程度,相当于 `h1`、`h2`、`h3`、`h4` | number: `1`, `2`, `3`, `4` | 1 | |
|
|
| mark | 添加标记样式 | boolean | false | |
|
|
| underline | 添加下划线样式 | boolean | false | |
|
|
| onChange | 当用户提交编辑内容时触发 | Function(string) | - | |
|
|
| type | 文本类型 | `secondary` \| `warning` \| `danger` | - | |
|
|
|
|
### Typography.Paragraph
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
| --- | --- | --- | --- | --- |
|
|
| copyable | 是否可拷贝,为对象时可设置复制文本以回调函数 | boolean \| { text: string, onCopy: Function } | false | |
|
|
| delete | 添加删除线样式 | boolean | false | |
|
|
| disabled | 禁用文本 | boolean | false | |
|
|
| editable | 是否可编辑,为对象时可对编辑进行控制 | boolean \| { editing: boolean, onStart: Function, onChange: Function(string) } | false | |
|
|
| ellipsis | 自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等 | boolean \| { rows: number, expandable: boolean, suffix: string, symbol: React.ReactNode, onExpand: Function(event), onEllipsis: Function(ellipsis) } | false | onEllipsis: 4.2.0 |
|
|
| mark | 添加标记样式 | boolean | false | |
|
|
| underline | 添加下划线样式 | boolean | false | |
|
|
| onChange | 当用户提交编辑内容时触发 | Function(string) | - | |
|
|
| strong | 是否加粗 | boolean | false | |
|
|
| type | 文本类型 | `secondary` \| `warning` \| `danger` | - | |
|
|
|
|
## FAQ
|
|
|
|
### Typography.Link 如何与 react-router 库集成?
|
|
|
|
`react-router` 支持[自定义](https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/Link.md#component-reactcomponent)渲染组件:
|
|
|
|
```tsx
|
|
<Link to="/" component={Typography.Link} />
|
|
```
|