Git Product home page Git Product logo

tabs's Introduction

@bumaga/tabs

Headless tabs component for React

Features

  • ๐Ÿ“ฆ super small, 381 B vs 3.5kB react-tabs
  • ๐Ÿšซ no styles, just logic. Style what you want, as you want
  • ๐ŸŽฃ componsents and hooks API

Install

npm install @bumaga/tabs
yarn add @bumaga/tabs

Usage

With components

import React from 'react'
import { Tabs, Tab, Panel } from '@bumaga/tabs' 

export default () => (
  <Tabs>
    <div>
      <Tab><button>Tab 1</button></Tab>
      <Tab><button>Tab 2</button></Tab>
      <Tab><button>Tab 3</button></Tab>
    </div>

    <Panel><p>Panel 1</p></Panel>
    <Panel><p>Panel 2</p></Panel>
    <Panel><p>panel 3</p></Panel>
  </Tabs>
);

With hooks

import React from "react";
import { Tabs, useTabState, usePanelState } from "@bumaga/tabs";

const Tab = ({ children }) => {
  const { onClick } = useTabState();

  return <button onClick={onClick}>{children}</button>;
};

const Panel = ({ children }) => {
  const isActive = usePanelState();

  return isActive ? <p>{children}</p> : null;
};

export default () => (
  <Tabs>
    <div>
      <Tab>Tab 1</Tab>
      <Tab>Tab 2</Tab>
    </div>

    <Panel>Panel 1</Panel>
    <Panel>Panel 2</Panel>
  </Tabs>
);

tabs's People

Contributors

jeetiss avatar thisgeek avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.