Home > Mobile >  how to style antd tabs component?
how to style antd tabs component?

Time:08-10

The below UI is of antd tabs. I need to expand the tab item but for some reason it doesn't work as expected.

Current UI: enter image description here

Desired UI: enter image description here

Code:

const App = () => (
  <Tabs
    defaultActiveKey="1"
    onChange={onChange}
    style={{ display: "flex", justifyContent: "space-between" }}
  >
    <TabPane tab="Details" key="1" style={{ width: "50%" }}>
      Content of Tab Pane 1
    </TabPane>
    <TabPane tab="Updates" key="2">
      Content of Tab Pane 2
    </TabPane>
  </Tabs>
);

Even though I have given justify-content:space-between or custom width it doesn't change.

Codesandbox: enter image description here

by applying tabBarStyle the CSS properties are appended to the upper div (the red container). In order to work it should be applied to the bottom div (the blue container):

enter image description here

You can try custom styling via CSS

EDIT #2:

This worked fine for me:

.ant-tabs-nav-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.ant-tabs-tab {
  width: 50%;
  justify-content: center;
}
  • Related