如何更改Ant Design卡片组件的标题字体?

3

我应该如何仅更改标题字体,但保留Ant Design卡片组件子元素的默认字体?

示例卡片组件:

// How to change title style
<Card title="Default" extra={<a href="#">More</a>} style={{ width: 300 }}>
  <p>Card content</p>
  <p>Card content</p>
  <p>Card content</p>
</Card>
1个回答

5

title属性接受ReactNode,因此您可以呈现任何React组件,特别是其样式:Card

import { Card, Typography } from 'antd';

const { Title } = Typography;

const App = () => (
  <Card title={<Title level={2}>Custom Title</Title>}>
    <p>Card Content</p>
  </Card>
);

title- 卡片标题 - string|ReactNode

Edit react-antd-styled-template


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接