Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-tabs

Package Overview
Dependencies
Maintainers
6
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-tabs

  • 0.1.6-rc.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-15.17%
Maintainers
6
Weekly downloads
 
Created

What is @radix-ui/react-tabs?

@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.

What are @radix-ui/react-tabs's main functionalities?

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

Other packages similar to @radix-ui/react-tabs

FAQs

Package last updated on 20 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc