Chuyển tới nội dung chính
Phiên bản: 1.11.0

implementation

Component giúp tổ chức và cho phép điều hướng giữa các nhóm nội dung có liên quan và ở cùng cấp độ.

Properties

Tabs

NameTypeDefaultDescription
itemsArrayMảng các tab cần hiển thị
activeKeystringChỉ định tab ở trạng thái active
defaultActiveKeystringChỉ định tab ở trạng thái active khi component được khởi tạo
scrollablebooleanChế độ scroll của tab
onChangefunctionThêm event handler khi tab thay đôi
onTabClickfunctionThêm event handler khi tab được click
renderTabBarRenderTabBarCustom tab bar
bottomBarbooleanHiển thị bottom bar
destroyInactiveTabPanebooleanDestroy các tab có trạng thái inactive

Tabs.Tab

NameTypeDefaultDescription
labelReactNodeLabel hiển thị của tab.
destroyInactiveTabPanebooleanDestroy khi tab có trạng thái inactive
tabKeystringKey của tab
activebooleanTrạng thái active của tab

Example

import React from "react";
import { Page, Tabs, List, Icon, Avatar } from "zmp-ui";

const alphabet = "abcdefghijklmnopqrstuvwxyz";
const users = Array.from(Array(10).keys()).map((i) => ({
  name: `Người dùng ${i}`,
  avatar: alphabet[Math.floor(Math.random() * alphabet.length)].toUpperCase(),
  online: Math.floor(Math.random() * 10) % 2 === 0,
  key: i,
}));

export default function HomePage(props) {
  return (
    <Page className="section-container">
      <Tabs id="contact-list">
        <Tabs.Tab key="tab1" label="Tab 1">
          <List>
            {users.map((user) => (
              <List.Item
                key={user.key}
                prefix={<Avatar online={user.online}>{user.avatar}</Avatar>}
                title={user.name}
                subTitle="subtitle"
                suffix={<Icon icon="zi-call" />}
              />
            ))}
          </List>
        </Tabs.Tab>
        <Tabs.Tab key="tab2" label="Tab 2">
          Tab 2 content
        </Tabs.Tab>
        <Tabs.Tab key="tab3" label="Tab 3">
          Tab 3 content
        </Tabs.Tab>
      </Tabs>
    </Page>
  );
}