Tabs
A component for toggling between related panels on the same page.
Workspace stats and activity.
Anatomy
Import the component and assemble its parts:
Examples
Animated panels
Animate panels as they activate using the data-starting-style and data-ending-style attributes.
The data-activation-direction attribute indicates which direction the newly active tab is relative to the previously active one, letting panels slide in from the correct side.
Workspace stats and activity.
Links
Use the render snippet and set nativeButton={false} on <Tabs.Tab> to render tabs as anchor elements.
API reference
Root
Groups the tabs and the corresponding panels. Renders a <div> element.
value TabsValue | null 0
- Name
- Description
The selected tab value. Use
bind:valueto share it with the parent. A value passed withoutbind:holds until the parent changes it. The root moves it to the first enabled tab when the selected tab is disabled or removed. A value passed at mount is held while its tab is disabled or not yet rendered.nullselects nothing.- Type
TabsValue | null- Default
0- Binding
bind:value
orientation TabsOrientation 'horizontal'
- Name
- Description
Layout direction. Arrow keys follow it.
- Type
TabsOrientation- Default
'horizontal'
onValueChange function —
- Name
- Description
Called when the selected value changes.
reasonisnonefor a click or keyboard activation,initialfor the first selection once the tabs mount,disabledwhen the selected tab becomes disabled, andmissingwhen it is removed.cancel()stops anonechange. It does not stop automatic changes.- Type
(value: TabsValue | null, eventDetails: TabsRootChangeEventDetails) => void
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsRootState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsRootState, children: Snippet | undefined]>
orientation TabsOrientation
- Name
orientation- Description
Layout direction. Exposed as
data-orientation.- Type
TabsOrientation
tabActivationDirection TabsActivationDirection
- Name
tabActivationDirection- Description
Where the active tab sits relative to the previous one.
- Type
TabsActivationDirection
data-orientation
data-activation-direction
List
Groups the individual tab buttons. Renders a <div> element.
activateOnFocus boolean false
- Name
- Description
When true, arrow keys select the tab they move to. When false, Enter or Space selects the focused tab.
- Type
boolean- Default
false
loopFocus boolean true
- Name
- Description
Whether arrow keys wrap from the last tab to the first.
- Type
boolean- Default
true
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsListState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsListState, children: Snippet | undefined]>
orientation TabsOrientation
- Name
orientation- Description
Layout direction. Exposed as
data-orientation.- Type
TabsOrientation
tabActivationDirection TabsActivationDirection
- Name
tabActivationDirection- Description
Where the active tab sits relative to the previous one.
- Type
TabsActivationDirection
data-orientation
data-activation-direction
Tab
An individual interactive tab button that toggles the corresponding panel. Renders a <button> element.
value* TabsValue —
- Name
- Description
Identifies this tab in the root
value.- Type
TabsValue
disabled boolean | null false
- Name
- Description
Whether this tab ignores activation. A disabled tab stays focusable. Arrow keys can land on it. When
valueis omitted, a disabled tab is not the initial selection.- Type
boolean | null- Default
false
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>. Setfalsewhenrendersupplies a non-button element.- Type
boolean- Default
true
onclick MouseEventHandler<HTMLElement> | null —
- Name
- Description
Runs before the tab's handler. Call
event.preventDefault()to skip it.- Type
MouseEventHandler<HTMLElement> | null
render Snippet<[props: TabsTabHostProps, state: TabsTabState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<button>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: TabsTabHostProps, state: TabsTabState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether this tab ignores activation.
- Type
boolean
active boolean
- Name
active- Description
Whether this tab's panel is the selected one.
- Type
boolean
orientation TabsOrientation
- Name
orientation- Description
Layout direction. Exposed as
data-orientation.- Type
TabsOrientation
tabActivationDirection TabsActivationDirection
- Name
tabActivationDirection- Description
Where the active tab sits relative to the previous one.
- Type
TabsActivationDirection
data-orientation
data-disabled
data-activation-direction
data-active
Indicator
A visual indicator aligned to the active tab. Renders a <span> element.
renderBeforeHydration boolean false
- Description
Whether to render itself before hydration. This minimizes the time that the indicator isn't visible after server-side rendering.
- Type
boolean- Default
false
render Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: TabsIndicatorState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<span>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: TabsIndicatorState, children: Snippet | undefined]>
activeTabPosition TabsTabPosition | null
- Name
activeTabPosition- Description
Active tab edges inside the list.
nullwhen nothing is selected.- Type
TabsTabPosition | null
activeTabSize TabsTabSize | null
- Name
activeTabSize- Description
Active tab size.
nullwhen nothing is selected.- Type
TabsTabSize | null
orientation TabsOrientation
- Name
orientation- Description
Layout direction. Exposed as
data-orientation.- Type
TabsOrientation
tabActivationDirection TabsActivationDirection
- Name
tabActivationDirection- Description
Where the active tab sits relative to the previous one.
- Type
TabsActivationDirection
data-orientation
data-activation-direction
--active-tab-bottom
--active-tab-height
--active-tab-left
--active-tab-right
--active-tab-top
--active-tab-width
Panel
A panel displayed when the corresponding tab is active. Renders a <div> element.
value* TabsValue —
- Name
- Description
Shown when the tab with the same value is selected.
- Type
TabsValue
keepMounted boolean false
- Name
- Description
Whether to keep the panel in the DOM while it is hidden.
- Type
boolean- Default
false
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsPanelState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: TabsPanelState, children: Snippet | undefined]>
hidden boolean
- Name
hidden- Description
Whether the panel is currently hidden.
- Type
boolean
transitionStatus TransitionStatus
- Name
transitionStatus- Description
Enter and exit motion phase.
- Type
TransitionStatus
orientation TabsOrientation
- Name
orientation- Description
Layout direction. Exposed as
data-orientation.- Type
TabsOrientation
tabActivationDirection TabsActivationDirection
- Name
tabActivationDirection- Description
Where the active tab sits relative to the previous one.
- Type
TabsActivationDirection