You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

---
order: 12
title:
zh-CN: 自定义页签头
en-US: Customized bar of tab
---
## zh-CN
使用 react-sticky 组件实现吸顶效果。
## en-US
Use react-sticky.
```jsx
import { Tabs } from 'antd';
import { StickyContainer, Sticky } from 'react-sticky';
const { TabPane } = Tabs;
const renderTabBar = (props, DefaultTabBar) => (
<Sticky bottomOffset={80}>
{({ style }) => (
5 years ago
<DefaultTabBar {...props} className="site-custom-tab-bar" style={{ ...style }} />
)}
</Sticky>
);
export default () => (
<StickyContainer>
<Tabs defaultActiveKey="1" renderTabBar={renderTabBar}>
<TabPane tab="Tab 1" key="1" style={{ height: 200 }}>
Content of Tab Pane 1
</TabPane>
<TabPane tab="Tab 2" key="2">
Content of Tab Pane 2
</TabPane>
<TabPane tab="Tab 3" key="3">
Content of Tab Pane 3
</TabPane>
</Tabs>
</StickyContainer>
);
```
5 years ago
```css
.site-custom-tab-bar {
z-index: 1;
background: #fff;
}
```
<style>
[data-theme="dark"] .site-custom-tab-bar {
background: #141414;
}
</style>