Skip to content

Tab

ETab is a collection of tab elements pointing to a separate content section or view. The tab bar organizes material across several displays and allows you to navigate between subsections.Demo Here

Import

jsx
import ETab from "@components/Elements/ETab";
import ETabItem from "@components/Elements/ETab/ETabItem";
import ETabContent from "@components/Elements/ETab/ETabContent";

Usage

The ETab, ETabItem and ETabContent components are used together as below:

jsx
// In this approach the ETabItem and ETabContent are linked together based on
// their order.

const TabExample = () => {
    const [activeTab, setActiveTab] = useState(0);

    const handleChange = (event, value) => {
        setActiveTab(value);
    };

    return (
        <ETab value={activeTab} onChange={handleChange}>
            <ETabItem> Item 1 </ETabItem>
            <ETabItem> Item 2 </ETabItem>
            <ETabContent>Content 1</ETabContent>
            <ETabContent>Content 2</ETabContent>
        </ETab>
    );
};

export default TabExample;
jsx
// User Custom Value

const TabExample = () => {
    const [activeTab, setActiveTab] = useState("second");

    // In this approach the `ETabItem` and `ETabContent` are linked together based
    // on their custom value.

    const handleChange = (event, value) => {
        setActiveTab(value);
    };

    return (
        <ETab value={activeTab} onChange={handleChange}>
            <ETabItem value="first"> Item 1 </ETabItem>
            <ETabItem value="second"> Item 2 </ETabItem>
            <ETabContent value="first">Content 1</ETabContent>
            <ETabContent value="second">Content 2</ETabContent>
        </ETab>
    );
};

export default TabExample;

Props

  • For ETab component, the following props are available:
PropTypeDefaultNote
value[String, Number]-Controls selected tab.
verticalBooleanfalseIt organizes your tabs vertically.
squareBooleanfalseRemoves rounded corners of the element.
growBooleanfalseMakes the tab items expand to fit the full container width.
alignString"start"Specifies how the tab items are distributed along the cross axis in a container.
stackedBooleanfalsePlaces an icon and text of the ETabItem behind each other on one line vertically.
variantString"fill"The ETab element can be represented in three ways: fill, alternate. alternate displays the chip with a light background.
colorString"primary"The given color is applied to the tab - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.
classNameString-Overrides or extends the component's wrapper styles.
headerClassNameString-Overrides or extends the header styles.
  • For ETabItem component, the following props are available:
PropTypeDefaultNote
valueBooleanfalseYou can Add your own value. If not, we will default to the index of the child position.
variantString"fill"The ETab element can be represented in three ways: fill, alternate. alternate displays the chip with a light background.
iconObject-By using icon prop the ETabItem element will be visualized with an Icon. More Info about icons here.
idString-HTML id attribute.
colorString"primary"The given color is applied to the tab - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.
stackedBooleanfalsePlaces an icon and text of the ETabItem behind each other on one line vertically.
classNameString-Overrides or extends the component's wrapper styles.
  • For ETabContent component, the following props are available:
PropTypeDefaultNote
idString-HTML id attribute.
valueBooleanfalseYou can Add your own value. If not, we will default to the index of the child position.
classNameString-Overrides or extends the component's wrapper styles.

Callback Functions

The ETab component contains following callback functions.

FunctionDescription
onChangeControls the active tab. function(event: React.SyntheticEvent, currentTab: Number) => void 👇

event: The event source of the callback.
currentTab: current tab value.

Children

The ETab component provides a children props that enable you to customize the content.

ChildrenDescription
ETabItemComponent’s items.
ETabContentComponent’s content.

The ETabItem and ETabContent component provide a children props that enable you to customize the content.

ChildrenDescription
✔️Component’s content.

COPYRIGHT