项目
在 GitHub 查看
jeetiss/tabs
关于
React tabs with hooks
网站与应用开发可以做什么
- 📦 super small, 381 B vs 3.5kB react-tabs
- 🚫 no styles, just logic. Style what you want, as you want
- 🎣 components and hooks API
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文@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
- 🎣 components 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>
);
探索相关项目
加载中…