Empty
Empty state placeholder.
When To Use#
When there is no data provided, display for friendly tips.
User tutorial to create something in fresh new situation.
Examples
No Data
import { Empty } from 'antd';
ReactDOM.render(<Empty />, mountNode);
No Data
import { Empty } from 'antd';
ReactDOM.render(<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />, mountNode);
Customize Description
import { Empty, Button } from 'antd';
ReactDOM.render(
<Empty
image="https://gw.alipayobjects.com/zos/antfincdn/ZHrcdLPrvN/empty.svg"
imageStyle={{
height: 60,
}}
description={
<span>
Customize <a href="#API">Description</a>
</span>
}
>
<Button type="primary">Create Now</Button>
</Empty>,
mountNode,
);
Select
TreeSelect
Cascader
Transfer
0 item
No Data
0 item
No Data
Table
Name | Age |
---|---|
No Data |
List
No Data
import {
ConfigProvider,
Switch,
Divider,
TreeSelect,
Select,
Cascader,
Transfer,
Table,
List,
} from 'antd';
import { SmileOutlined } from '@ant-design/icons';
const customizeRenderEmpty = () => (
<div style={{ textAlign: 'center' }}>
<SmileOutlined style={{ fontSize: 20 }} />
<p>Data Not Found</p>
</div>
);
const style = { width: 200 };
class Demo extends React.Component {
state = {
customize: false,
};
render() {
const { customize } = this.state;
return (
<div>
<Switch
unCheckedChildren="default"
checkedChildren="customize"
checked={customize}
onChange={val => {
this.setState({ customize: val });
}}
/>
<Divider />
<ConfigProvider renderEmpty={customize && customizeRenderEmpty}>
<div className="config-provider">
<h4>Select</h4>
<Select style={style} />
<h4>TreeSelect</h4>
<TreeSelect style={style} treeData={[]} />
<h4>Cascader</h4>
<Cascader style={style} options={[]} showSearch />
<h4>Transfer</h4>
<Transfer />
<h4>Table</h4>
<Table
style={{ marginTop: 8 }}
columns={[
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
]}
/>
<h4>List</h4>
<List />
</div>
</ConfigProvider>
</div>
);
}
}
ReactDOM.render(<Demo />, mountNode);
import { Empty } from 'antd';
ReactDOM.render(<Empty description={false} />, mountNode);
API#
<Empty>
<Button>Create</Button>
</Empty>
Property | Description | Type | Default | Version |
---|---|---|---|---|
description | Customize description | ReactNode | - | |
image | Customize image. Will treat as image url when string provided | ReactNode | Empty.PRESENTED_IMAGE_DEFAULT | |
imageStyle | The style of image | CSSProperties | - |
Built-in images#
Empty.PRESENTED_IMAGE_SIMPLE
Empty.PRESENTED_IMAGE_DEFAULT