🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@radix-ui/react-tabs

Package Overview
Dependencies
Maintainers
6
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-tabs

View docs [here](https://radix-ui.com/primitives/docs/components/tabs).

1.1.12
latest
Source
npm
Version published
Weekly downloads
7.3M
12.07%
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 2025

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