Tabs are used to help group various related content into separate sections. Those sections can be all or contained in a portion of the screen. We recommend using one set of tabs per screen and also only using it for different related content types. For example, when you have different data about a single entity, you might bucket the data into different sections.
Do NOT separate an action, like create, from other content sections in tabs. The action should be triggered by an icon or button and open either a modal or stacked page.
Usage
import { Tabs } from 'nr1'
Examples
Basic
<Tabs defaultValue="tab-3"> <TabsItem value="tab-1" label="Tab 1"> Tab 1 content </TabsItem> <TabsItem value="tab-2" label="Another tab with a longer name"> Tab 2 content </TabsItem> <TabsItem value="tab-3" label="A tab open by default"> Tab 3 content </TabsItem></Tabs>
Render Callback
function render() { const items = new Array(10000).fill().map((_, i) => ({ value: i, content: `Tab ${i} content...`, label: `Item ${i}`, }));
return ( <div className="nr1-Example--tabs"> <Tabs items={items}> {({ item }) => ( <TabsItem value={item.value} label={item.label}> {item.content} </TabsItem> )} </Tabs> </div> );}
Props
string | Provide an accessibility label that describes the purpose of the set of tabs, e.g. |
REQUIREDnode|function | It can be either an array of |
string | Appends class names to the component.Should be used only for positioning and spacing purposes. |
any |
|
shape[] | The items to render, which required when rendering items with the render callback (Function as Children).The item must contain shape
REQUIREDany
REQUIREDstring
boolean
|
function | Callback fired any time the selected tab changes. function ( |
enum[] | Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like <Array of |
object | Inline style for custom styling. |
string | Adds a Note: You might not see |
any | When you need to have a tab other than the first open by default, use the pre-selected tab. Before using this option, we recommend considering if you have the right tab order for your experience.If defined, it turns the component into a controlled component. |
Type definitions
RenderCallbackArguments
{item: any, Item to render.
index: number, Index of the item in the items array.
items: any[], Array of items which we're iterating on.
}