@bomihooks/use-tabs

1.0.0 • Public • Published

@bomihooks/use-tabs

React Hook to implement tab
Example

import { useTabs } from "@bomihooks/use-tabs";

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"
  }
];

export default function App() {
  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 @bomihooks/use-tabs

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.51 kB

Total Files

3

Last publish

Collaborators

  • hibomi97