Skip to content

Repository files navigation

@rc-component/tabs

Ant Design Part of the Ant Design ecosystem.

📑 Flexible React tabs with overflow, editable items, custom tab bars, and accessible panels.

NPM versionnpm downloadsbuild statusCodecovbundle sizedumi

English | 简体中文

Highlights

  • Supports top, bottom, left, and right tab positions with RTL layouts.
  • Handles overflow with a dropdown operation menu.
  • Supports editable tabs, extra tab bar content, indicators, and custom tab bars.
  • Provides semantic classNames and styles slots for panel and navigation customization.

Install

npm install @rc-component/tabs

Usage

importTabsfrom'@rc-component/tabs';import'@rc-component/tabs/assets/index.css';constitems=[{key: 'overview',label: 'Overview',children: 'Overview content'},{key: 'settings',label: 'Settings',children: 'Settings content'},];exportdefault()=><Tabsitems={items}defaultActiveKey="overview"/>;

Online preview: https://tabs.react-component.vercel.app/

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Tabs

NameTypeDefaultDescription
activeKeystring-Controlled active tab key.
animatedboolean | AnimatedConfig{ inkBar: true, tabPane: false }Animation config.
classNamestring-Additional class name.
classNamesPartial<Record<SemanticName, string>>-Semantic class names.
defaultActiveKeystring-Initial active tab key.
destroyOnHiddenbooleanfalseDestroy inactive tab panels.
direction'ltr' | 'rtl''ltr'Layout direction.
editableEditableConfig-Editable tab configuration.
getPopupContainer(node: HTMLElement) => HTMLElement-Popup container resolver.
idstring-Root id.
indicator{ size?: GetIndicatorSize; align?: 'start' | 'center' | 'end' }-Indicator size and alignment.
itemsTab[][]Tab items.
localeTabsLocale-Accessibility locale text.
moreMoreProps-more dropdown config, see MoreProps for full API. Additionally supports popupRender for custom popup content.
onChange(activeKey: string) => void-Triggered when active tab changes.
onTabClick(activeKey, event) => void-Triggered when a tab is clicked.
onTabScroll({ direction }) => void-Triggered when tab navigation scrolls.
prefixClsstring'rc-tabs'Prefix class name.
renderTabBarRenderTabBar-Custom tab bar renderer.
styleReact.CSSProperties-Root style.
stylesPartial<Record<SemanticName, React.CSSProperties>>-Semantic styles.
tabBarExtraContentReact.ReactNode | TabBarExtraMap-Extra content beside the tab bar.
tabBarGutternumber0Gap between tabs.
tabBarStyleReact.CSSProperties-Tab bar style.
tabPosition'left' | 'right' | 'top' | 'bottom''top'Tab position.

Tab

NameTypeDefaultDescription
childrenReact.ReactNode-Tab panel content.
classNamestring-Panel class name.
closableboolean-Whether the tab can be closed in editable mode.
closeIconReact.ReactNode-Custom close icon.
destroyOnHiddenbooleanfalseDestroy inactive panel.
disabledbooleanfalseDisable the tab.
forceRenderbooleanfalseRender panel before it becomes active.
keystring-Required unique tab key.
labelReact.ReactNode-Tab label.
styleReact.CSSProperties-Panel style.

MoreProps

NameTypeDefaultDescription
iconReactNode-The icon shown in the more trigger.
popupRender(menu: ReactElement, info: { restTabs: Tab[], onClose: () => void }) => ReactElement-Customize the dropdown popup content. The info object provides restTabs (all overflowed tabs) and onClose (function to close the dropdown).
Other dropdown propsfrom DropdownProps-All other rc-dropdown props such as trigger, overlayClassName, visible, etc. are also supported.

Development

npm install
npm start
npm test
npm run tsc
npm run compile
npm run build

The dumi site runs at http://localhost:8000 by default.

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/tabs is released under the MIT license.

About

📑 Flexible React tabs with overflow, editable items, custom tab bars, and accessible panels.

Topics

Resources

Stars

572 stars

Watchers

14 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages