--- title: Tabs description: A Tabs component built with Radix UI, with additional features such as persistent and shared value. preview: tabs --- ## Usage Import it in your MDX documents. ```mdx import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; Javascript is weird Rust is fast ``` ### Without `value` Without a `value`, it detects from the children index. Note that it might cause errors on re-renders, it's not encouraged if the tabs might change. ```mdx import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; Javascript is weird Rust is fast ``` #### Demo with Re-renders Javascript is weird Rust is fast {/* */} ### Shared Value By passing an `groupId` property, you can share a value across all tabs with the same id. ```mdx Javascript is weird Rust is fast ``` ### Persistent You can enable persistent by passing a `persist` property. The value will be stored in `localStorage`, with its id as the key. ```mdx Javascript is weird Rust is fast ``` > Persistent only works if you have passed an `id`. ### Default Value Set a default value by passing `defaultIndex`. ```mdx Javascript is weird Rust is fast ``` ### Link to Tab Use HTML `id` attribute to link to a specific tab. ```mdx Javascript is weird Rust is fast `Hello World` ``` You can add the hash `#tab-cpp` to your URL and reload, the C++ tab will be activated. Javascript is weird Rust is fast `Hello World` Additionally, the `updateAnchor` property can be set to `true` in the `Tabs` component to automatically update the URL hash whenever time a new tab is selected: ```mdx Javascript is weird Rust is fast `Hello World` ``` {/* */} Hello! World! ### Advanced You can use the styled Radix UI primitive directly from exported `Primitive`. ```mdx import { Primitive } from 'fumadocs-ui/components/tabs'; ```