Tabs
Shows one panel at a time from a row of tabs.
Arrow keys move between tabs, and Home and End jump to the first and last. Name the list
with aria-label.
Dependencies
What it's built from and what's built from it in Mocha, read from the imports in its source.
| Uses | Textprimitive |
|---|---|
| Used by | Nothing yet. |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20 |
Installation
Set the project up for Mocha once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Mocha's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Tabs
Holds a list of tabs and the panels they show.
- activation
Type "manual" | "automatic"
- className
Type string | ((state: TabsState<string>) => string)
- controller
Type { getValue: () => string | null; setValue: (value: string | null, options?: TabsChangeOptions) => boolean; select: (value: string, options?: TabsChangeOptions) => boolean; focus: () => void; } | undefined
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- defaultValue
Type string | null
- hiddenUntilFound
Type boolean
- onValueChange
Type ((value: string | null, details: { reason: "imperative"; event?: undefined; source: ChangeSource; cancel: () => void; readonly canceled: boolean; } | { reason: "item-press"; event?: MouseEvent | KeyboardEvent; source: ChangeSource; cancel: () => void; readonly canceled: boolean; } | { ...; } | { ...; } | { ...; }) =...
- orientation
Type TabsOrientation
- render
Type RenderProp<TabsState<string>>
- style
Type CSSProperties | ((state: TabsState<string>) => CSSProperties)
- value
Type string | null
TabsList
The row of tabs. Name it with aria-label.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<TabsListState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<TabsListState>) => string)
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<TabsListState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<TabsListState>) => CSSProperties)
TabsPanel
The content a tab shows.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<TabsPanelState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<TabsPanelState>) => string)
- hiddenUntilFound
Whether the panel stays findable with
hidden="until-found"while its tab isn't selected. Overrides the tabs'.Type boolean
- keepMounted
Whether the panel stays in the page, hidden, while its tab isn't selected.
Type boolean · Default false
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<TabsPanelState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<TabsPanelState>) => CSSProperties)
- value*
The value of the tab this panel belongs to.
Type string
TabsTab
One tab. Its value matches the panel it shows.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<TabsTabState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<TabsTabState>) => string)
- disabled
Keeps the tab focusable but stops it from being selected, as the tabs pattern asks.
Type boolean
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<TabsTabState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<TabsTabState>) => CSSProperties)
- value*
Identifies the tab and pairs it with the panel of the same value.
Type string