1.0.1 • Published 9 months ago

@smooks/use-tabs v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@smooks/use-tabs

React hook for handling tab navigation.

Installation

yarn

yarn add @smooks/use-tabs

npm

npm i @smooks/use-tabs

Usage

    const content = [
        {
            tab: "Section 1",
            content: "I'm the content of the Section 1"
        },
        {
            tab: "Section 2",
            content: "I'm the content of the Section 2"
        }
    ];
    
    const Tab = () => {
    const { currentItem, changeItem } = useTabs(0, content);
    return (
        <div className="App">
            {content.map((section, index) => (
            <button onClick={() => changeItem(index)}>{section.tab}</button>
            ))}
        <div>{currentItem.content}</div>
        </div>
    );
};
1.0.1

9 months ago

1.0.0

9 months ago