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

Car*_*ein 3 javascript reactjs antd

如何更改标题字体但保留 Ant Design 的 Card 组件子组件的默认字体?

样本卡组件:

// 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>
Run Code Online (Sandbox Code Playgroud)

Den*_*ash 5

titleCardAccept的属性ReactNode,因此您可以渲染任何 React 组件,特别是其样式:

import { Card, Typography } from 'antd';

const { Title } = Typography;

const App = () => (
  <Card title={<Title level={2}>Custom Title</Title>}>
    <p>Card Content</p>
  </Card>
);
Run Code Online (Sandbox Code Playgroud)

title- 卡标题 -string|ReactNode

编辑react-antd-styled-template