Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@radix-ui/react-tabs
Advanced tools
@radix-ui/react-tabs is a React component library for creating accessible and customizable tab interfaces. It provides a set of components and hooks to build tabbed navigation systems with ease, ensuring accessibility and flexibility.
Basic Tabs
This code demonstrates a basic tab interface with two tabs. The `Tabs`, `TabsList`, `TabsTrigger`, and `TabsContent` components are used to create a simple tabbed navigation system.
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@radix-ui/react-tabs';
function BasicTabs() {
return (
<Tabs defaultValue="tab1">
<TabsList>
<TabsTrigger value="tab1">Tab 1</TabsTrigger>
<TabsTrigger value="tab2">Tab 2</TabsTrigger>
</TabsList>
<TabsContent value="tab1">Content for Tab 1</TabsContent>
<TabsContent value="tab2">Content for Tab 2</TabsContent>
</Tabs>
);
}
Controlled Tabs
This code demonstrates a controlled tab interface where the active tab is managed by the component's state. The `value` and `onValueChange` props are used to control the active tab.
import { useState } from 'react';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@radix-ui/react-tabs';
function ControlledTabs() {
const [value, setValue] = useState('tab1');
return (
<Tabs value={value} onValueChange={setValue}>
<TabsList>
<TabsTrigger value="tab1">Tab 1</TabsTrigger>
<TabsTrigger value="tab2">Tab 2</TabsTrigger>
</TabsList>
<TabsContent value="tab1">Content for Tab 1</TabsContent>
<TabsContent value="tab2">Content for Tab 2</TabsContent>
</Tabs>
);
}
Custom Styling
This code demonstrates how to apply custom styling to the tab components. By adding class names to the `TabsList`, `TabsTrigger`, and `TabsContent` components, you can style them using CSS.
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@radix-ui/react-tabs';
import './CustomTabs.css';
function CustomTabs() {
return (
<Tabs defaultValue="tab1">
<TabsList className="custom-tabs-list">
<TabsTrigger className="custom-tabs-trigger" value="tab1">Tab 1</TabsTrigger>
<TabsTrigger className="custom-tabs-trigger" value="tab2">Tab 2</TabsTrigger>
</TabsList>
<TabsContent className="custom-tabs-content" value="tab1">Content for Tab 1</TabsContent>
<TabsContent className="custom-tabs-content" value="tab2">Content for Tab 2</TabsContent>
</Tabs>
);
}
react-tabs is a simple and fully accessible React tabs component. It provides a straightforward API for creating tabbed interfaces and ensures accessibility out of the box. Compared to @radix-ui/react-tabs, react-tabs is more lightweight but may offer fewer customization options.
Material-UI is a popular React UI framework that includes a comprehensive set of components, including Tabs. The Tabs component in Material-UI is highly customizable and follows the Material Design guidelines. It offers more features and styling options compared to @radix-ui/react-tabs but comes with a larger bundle size.
Chakra UI is a modern React UI library that provides a set of accessible and composable components, including Tabs. The Tabs component in Chakra UI is easy to use and highly customizable. It offers a similar level of flexibility and accessibility as @radix-ui/react-tabs but with a different design system.
react-tabs
$ yarn add @radix-ui/react-tabs
# or
$ npm install @radix-ui/react-tabs
View docs here.
FAQs
Unknown package
The npm package @radix-ui/react-tabs receives a total of 1,293,743 weekly downloads. As such, @radix-ui/react-tabs popularity was classified as popular.
We found that @radix-ui/react-tabs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.