@smooks/use-tabs

1.0.1 • Public • Published

@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>
    );
};

Readme

Keywords

Package Sidebar

Install

npm i @smooks/use-tabs

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

1.72 kB

Total Files

4

Last publish

Collaborators

  • 0724ksm