Tabs
A Tabs component built with Radix UI, with additional features such as persistent and shared value.
Usage
Import it in your MDX documents.
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.
Demo with Re-renders
Shared Value
By passing an id
property, you can share a value across all tabs with the same
id.
Persistent
You can enable persistent by passing a persist
property. The value will be
stored in localStorage
, with its id as the key.
Persistent only works if you have passed an id
.
Default Value
Set a default value by passing defaultIndex
.
Link to Tab
Use HTML id
attribute to link to a specific tab.
You can add the hash #tab-cpp
to your URL and reload, the C++ tab will be activated.
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:
Hello!
Advanced
You can use the styled Radix UI primitive directly from exported Primitive
.
Last updated on