rc-tabs is a foundational React UI component designed to provide a highly flexible and accessible tab interface. It is part of the `react-component` ecosystem, focusing on delivering core functionality without imposing specific styling, allowing developers to integrate it seamlessly into various design systems. The current stable version is 15.7.0, with regular updates that typically occur weekly or bi-weekly, addressing bug fixes, accessibility enhancements, and minor feature additions. Its key differentiators include built-in keyboard navigation for improved accessibility, extensive customization options via `prefixCls`, `className`, `style`, and `renderTabBar` props, and a commitment to being a lightweight, unstyled component. This makes `rc-tabs` an ideal choice for projects requiring a robust tab solution that prioritizes control over visual presentation.
npm install rc-tabsVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic `rc-tabs` setup with static content, keyboard navigation, custom styling, and an `onChange` callback, rendered using React 18's createRoot.
Replace `destroyInactiveTabPane` with `destroyOnHidden` in your `Tabs` component props. For example: `<Tabs destroyOnHidden={true} />`.For controlled tabs, always use `activeKey` in conjunction with the `onChange` prop to update the state controlling `activeKey`. For uncontrolled tabs, use `defaultActiveKey` only for initial render.
Prefer using the `tabPosition` prop to control the placement of the tab navigation bar.
Ensure every object in the `items` array has a unique `key` string property. If using a custom `renderTabBar`, explicitly assign unique `key` props to each tab element you render.
If `activeKey` is used, ensure the `onChange` handler updates the state that `activeKey` depends on. Verify no other component within the Tabs tree is causing uncontrolled re-renders by calling `setState` directly or indirectly in a render cycle.