Skip to main content

Tabs

v.3.1.0

Installation

yarn add @mercell/tabs-react

Usage

Using the Ribbon component is as simple as importing it like this.

import { Tab, Tabs } from '@mercell/tabs-react';
Live Editor
Result

Types, definitions, etc.

TabsProps
interface TabsProps {
hideLine?: boolean;
activeKey: string;
onTabChange: (tabKey: string) => void;
tabsClassName?: string;
tabContainerClassName?: string;
tabContentContainerClassName?: string;
tabsLineClassName?: string;
}
NameTypeDefaultRequiredDescription
hideLinebooleanfalsenoOptional switch for the underline between the tabs and the tab content
activeKeystring-yesSets the active starting key as well as updating the active tab if value is updated
onTabChange(tabKey: string) => void-yesWhat happens when a tab is clicked. Should follow the example to set a state that feeds into Tabs activeKey prop to change the active tab
tabsClassNamestring-noCustom className being added to the tabs parent element
tabContainerClassNamestring-noCustom className being added to the container containing the tabs
tabContentContainerClassNamestring-noCustom className being added to the container containing the tabs content
tabsLineClassNamestring-noCustom className being added to the container containing the dividing line
TabProps
interface TabProps {
title: string;
tabKey: string;
icon?: ReactNode;
}
NameTypeDefaultRequiredDescription
titlestring-yesTitle for the tab
tabKeystring-yesUnique key to identify the tab. Used while selecting the activeKey in Tabs
icon?ReactNode-noAllows to add a custom icon