beta

Tabs

Tabs organize content into multiple sections and allow users to navigate between them. The content under the set of tabs should be related and form a coherent unit.

installyarn add @react-spectrum/tabs
version3.0.0-beta.0
usageimport {Tabs, Item} from '@react-spectrum/tabs'

Example#


import {Content} from '@react-spectrum/view';
import {Text} from '@react-spectrum/text';

<Tabs aria-label="History of Ancient Rome">
  <Item title="Founding of Rome" key="FoR">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>Arma virumque cano, Troiae qui primus ab oris.</Text>
    </Content>
  </Item>
  <Item title="Monarchy and Republic" key="MaR">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>Senatus Populusque Romanus.</Text>
    </Content>
  </Item>
  <Item title="Empire" key="Emp">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>Alea jacta est.</Text>
    </Content>
  </Item>
</Tabs>
import {Content} from '@react-spectrum/view';
import {Text} from '@react-spectrum/text';

<Tabs aria-label="History of Ancient Rome">
  <Item title="Founding of Rome" key="FoR">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        Arma virumque cano, Troiae qui primus ab oris.
      </Text>
    </Content>
  </Item>
  <Item title="Monarchy and Republic" key="MaR">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>Senatus Populusque Romanus.</Text>
    </Content>
  </Item>
  <Item title="Empire" key="Emp">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>Alea jacta est.</Text>
    </Content>
  </Item>
</Tabs>
import {Content} from '@react-spectrum/view';
import {Text} from '@react-spectrum/text';

<Tabs aria-label="History of Ancient Rome">
  <Item
    title="Founding of Rome"
    key="FoR">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        Arma virumque
        cano, Troiae
        qui primus ab
        oris.
      </Text>
    </Content>
  </Item>
  <Item
    title="Monarchy and Republic"
    key="MaR">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        Senatus
        Populusque
        Romanus.
      </Text>
    </Content>
  </Item>
  <Item
    title="Empire"
    key="Emp">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        Alea jacta est.
      </Text>
    </Content>
  </Item>
</Tabs>

Content#


Tabs follows the Collection Components API, accepting both static and dynamic collections. Similar to Menu, Tabs accepts <Item> elements as children, each with a key prop. The content of the Tab itself is defined via the title prop passed to the <Item> element whereas the contents of the Tab's panel are defined by the <Item> element's children. This can be seen in the example above, where each Tab's rendered title mirrors the string provided to the <Item>'s title prop and the content of each Tab is populated by the <Item>'s children. Static collections, as in this example, can be used when the full list of tabs and their contents is known ahead of time.

Dynamic collections, as shown below, can be used when the options come from an external data source such as an API call, or update over time. As seen below, an iterable list of options is passed to the Tabs using the items prop. Each item accepts a key prop, which is passed to the onSelectionChange handler to identify the selected item. Alternatively, if the item objects contain an id property, as shown in the example below, then this is used automatically and a key prop is not required. See the Events section for more detail on selection.

function Example() {
  let tabs = [
    {
      id: 1,
      name: 'Founding of Rome',
      children: 'Arma virumque cano, Troiae qui primus ab oris.'
    },
    {
      id: 2,
      name: 'Monarchy and Republic',
      children: 'Senatus Populusque Romanus.'
    },
    {id: 3, name: 'Empire', children: 'Alea jacta est.'}
  ];
  let [tabId, setTabId] = React.useState(1);

  return (
    <>
      <p>Current tab id: {tabId}</p>
      <Tabs
        aria-label="History of Ancient Rome"
        items={tabs}
        onSelectionChange={setTabId}>
        {(item) => (
          <Item title={item.name}>
            <Content marginTop="size-250" marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}
function Example() {
  let tabs = [
    {
      id: 1,
      name: 'Founding of Rome',
      children:
        'Arma virumque cano, Troiae qui primus ab oris.'
    },
    {
      id: 2,
      name: 'Monarchy and Republic',
      children: 'Senatus Populusque Romanus.'
    },
    {id: 3, name: 'Empire', children: 'Alea jacta est.'}
  ];
  let [tabId, setTabId] = React.useState(1);

  return (
    <>
      <p>Current tab id: {tabId}</p>
      <Tabs
        aria-label="History of Ancient Rome"
        items={tabs}
        onSelectionChange={setTabId}>
        {(item) => (
          <Item title={item.name}>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}
function Example() {
  let tabs = [
    {
      id: 1,
      name:
        'Founding of Rome',
      children:
        'Arma virumque cano, Troiae qui primus ab oris.'
    },
    {
      id: 2,
      name:
        'Monarchy and Republic',
      children:
        'Senatus Populusque Romanus.'
    },
    {
      id: 3,
      name: 'Empire',
      children:
        'Alea jacta est.'
    }
  ];
  let [
    tabId,
    setTabId
  ] = React.useState(1);

  return (
    <>
      <p>
        Current tab id:{' '}
        {tabId}
      </p>
      <Tabs
        aria-label="History of Ancient Rome"
        items={tabs}
        onSelectionChange={
          setTabId
        }>
        {(item) => (
          <Item
            title={
              item.name
            }>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                {
                  item.children
                }
              </Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}

Internationalization#

To internationalize Tabs, a localized string should be passed to the title of each item. Any text content within the Tab's panel should also be localized accordingly. For languages that are read right-to-left (e.g. Hebrew and Arabic), the layout of Tabs is automatically flipped.

Labeling#


Accessibility#

While an aria-label is not explicitly required for a tab list, Tabs should be labeled using a aria-label in the absence of an ancestor landmark. This will prevent screen readers from announcing non-focused tabs, allowing for a more focused experience.

Selection#


Setting a selected tab can be done by using the defaultSelectedKey or selectedKey prop. The selected key corresponds to the key of an item. See Events for more details on selection events.

function Example() {
  let tabs = [
    {id: 1, name: 'Keyboard Settings', children: 'No keyboard detected.'},
    {id: 2, name: 'Mouse Settings', children: 'No mouse detected.'},
    {id: 3, name: 'Gamepad Settings', children: 'No gamepad detected'}
  ];
  let [tab, setTab] = React.useState(2);

  return (
    <Flex gap="size-150" wrap>
      <span id="label-2">Settings (uncontrolled)</span>
      <Tabs
        aria-labelledby="label-2"
        items={tabs}
        defaultSelectedKey={2}
        marginBottom="size-400">
        {(item) => (
          <Item title={item.name}>
            <Content marginTop="size-250" marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
      <span id="label-3">Settings (controlled)</span>
      <Tabs
        aria-labelledby="label-3"
        items={tabs}
        selectedKey={tab}
        onSelectionChange={setTab}>
        {(item) => (
          <Item title={item.name}>
            <Content marginTop="size-250" marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </Flex>
  );
}
function Example() {
  let tabs = [
    {
      id: 1,
      name: 'Keyboard Settings',
      children: 'No keyboard detected.'
    },
    {
      id: 2,
      name: 'Mouse Settings',
      children: 'No mouse detected.'
    },
    {
      id: 3,
      name: 'Gamepad Settings',
      children: 'No gamepad detected'
    }
  ];
  let [tab, setTab] = React.useState(2);

  return (
    <Flex gap="size-150" wrap>
      <span id="label-2">Settings (uncontrolled)</span>
      <Tabs
        aria-labelledby="label-2"
        items={tabs}
        defaultSelectedKey={2}
        marginBottom="size-400">
        {(item) => (
          <Item title={item.name}>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
      <span id="label-3">Settings (controlled)</span>
      <Tabs
        aria-labelledby="label-3"
        items={tabs}
        selectedKey={tab}
        onSelectionChange={setTab}>
        {(item) => (
          <Item title={item.name}>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </Flex>
  );
}
function Example() {
  let tabs = [
    {
      id: 1,
      name:
        'Keyboard Settings',
      children:
        'No keyboard detected.'
    },
    {
      id: 2,
      name:
        'Mouse Settings',
      children:
        'No mouse detected.'
    },
    {
      id: 3,
      name:
        'Gamepad Settings',
      children:
        'No gamepad detected'
    }
  ];
  let [
    tab,
    setTab
  ] = React.useState(2);

  return (
    <Flex
      gap="size-150"
      wrap>
      <span id="label-2">
        Settings
        (uncontrolled)
      </span>
      <Tabs
        aria-labelledby="label-2"
        items={tabs}
        defaultSelectedKey={
          2
        }
        marginBottom="size-400">
        {(item) => (
          <Item
            title={
              item.name
            }>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                {
                  item.children
                }
              </Text>
            </Content>
          </Item>
        )}
      </Tabs>
      <span id="label-3">
        Settings
        (controlled)
      </span>
      <Tabs
        aria-labelledby="label-3"
        items={tabs}
        selectedKey={tab}
        onSelectionChange={
          setTab
        }>
        {(item) => (
          <Item
            title={
              item.name
            }>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                {
                  item.children
                }
              </Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </Flex>
  );
}

Events#


Tabs supports selection via mouse, keyboard, and touch. You can handle all of these via the onSelectionChange prop. Tabs will pass the selected key to the onSelectionChange handler.

The following example uses an onSelectionChange handler to update the tab selection stored in React state.

function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];
  let [timePeriod, setTimePeriod] = React.useState('Triassic');

  return (
    <>
      <p>Selected time period: {timePeriod}</p>
      <Tabs
        aria-label="Mesozoic time periods"
        items={tabs}
        selectedKey={timePeriod}
        onSelectionChange={setTimePeriod}>
        {(item) => (
          <Item title={item.name} key={item.name}>
            <Content marginTop="size-250" marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}
function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];
  let [timePeriod, setTimePeriod] = React.useState(
    'Triassic'
  );

  return (
    <>
      <p>Selected time period: {timePeriod}</p>
      <Tabs
        aria-label="Mesozoic time periods"
        items={tabs}
        selectedKey={timePeriod}
        onSelectionChange={setTimePeriod}>
        {(item) => (
          <Item title={item.name} key={item.name}>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>{item.children}</Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}
function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];
  let [
    timePeriod,
    setTimePeriod
  ] = React.useState(
    'Triassic'
  );

  return (
    <>
      <p>
        Selected time
        period:{' '}
        {timePeriod}
      </p>
      <Tabs
        aria-label="Mesozoic time periods"
        items={tabs}
        selectedKey={
          timePeriod
        }
        onSelectionChange={
          setTimePeriod
        }>
        {(item) => (
          <Item
            title={
              item.name
            }
            key={
              item.name
            }>
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                {
                  item.children
                }
              </Text>
            </Content>
          </Item>
        )}
      </Tabs>
    </>
  );
}

Keyboard Activation#

By default, pressing the arrow keys while focus is on a Tab will switch selection to the adjacent Tab in that direction, updating the content displayed accordingly. If you would like to prevent selection change from happening automatically you can set the keyboardActivation prop to "manual". This will prevent tab selection from changing on arrow key press, requiring a subsequent Enter or Space key press to confirm tab selection.

function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];

  return (
    <Tabs
      aria-label="Mesozoic time periods"
      items={tabs}
      keyboardActivation="manual">
      {(item) => (
        <Item title={item.name} key={item.name}>
          <Content marginTop="size-250" marginStart="size-125">
            <Text>{item.children}</Text>
          </Content>
        </Item>
      )}
    </Tabs>
  );
}
function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];

  return (
    <Tabs
      aria-label="Mesozoic time periods"
      items={tabs}
      keyboardActivation="manual">
      {(item) => (
        <Item title={item.name} key={item.name}>
          <Content
            marginTop="size-250"
            marginStart="size-125">
            <Text>{item.children}</Text>
          </Content>
        </Item>
      )}
    </Tabs>
  );
}
function Example() {
  let tabs = [
    {
      name: 'Triassic',
      children:
        'The Triassic ranges roughly from 252 million to 201 million years ago, preceding the Jurassic Period.'
    },
    {
      name: 'Jurassic',
      children:
        'The Jurassic ranges from 200 million years to 145 million years ago.'
    },
    {
      name: 'Cretaceous',
      children:
        'The Cretaceous is the longest period of the Mesozoic, spanning from 145 million to 66 years ago.'
    }
  ];

  return (
    <Tabs
      aria-label="Mesozoic time periods"
      items={tabs}
      keyboardActivation="manual">
      {(item) => (
        <Item
          title={
            item.name
          }
          key={
            item.name
          }>
          <Content
            marginTop="size-250"
            marginStart="size-125">
            <Text>
              {
                item.children
              }
            </Text>
          </Content>
        </Item>
      )}
    </Tabs>
  );
}

Props#


NameTypeDefaultDescription
childrenCollectionChildren<T>The contents of the collection.
isQuietbooleanWhether the Tabs should be displayed with a quiet style.
density'compact''regular''regular'Sets the amount of space between the Tab and the Tab rail.
isDisabledbooleanWhether Tabs are disabled.
selectedKeyKeyThe currently selected Tab key in the collection (controlled).
defaultSelectedKeyKeyThe initial selected Tab key in the collection (uncontrolled).
keyboardActivation'automatic''manual''automatic'Whether tabs are activated automatically on focus or manually.
orientationOrientation'horizontal'The orientation of the tabs.
itemsIterable<T>Item objects in the collection.
disabledKeysIterable<Key>The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.
disallowEmptySelectionbooleanWhether the collection allows empty selection.
Events
NameTypeDefaultDescription
onSelectionChange( (selectedItem: Key )) => voidHandler that is called when the tab selection changes.
Layout
NameTypeDefaultDescription
flexstringnumberbooleanWhen used in a flex layout, specifies how the element will grow or shrink to fit the space available. See MDN.
flexGrownumberWhen used in a flex layout, specifies how the element will grow to fit the space available. See MDN.
flexShrinknumberWhen used in a flex layout, specifies how the element will shrink to fit the space available. See MDN.
flexBasisnumberstringWhen used in a flex layout, specifies the initial main size of the element. See MDN.
alignSelf'auto''normal''start''end''center''flex-start''flex-end''self-start''self-end''stretch'Overrides the alignItems property of a flex or grid container. See MDN.
justifySelf'auto''normal''start''end''flex-start''flex-end''self-start''self-end''center''left''right''stretch'Specifies how the element is justified inside a flex or grid container. See MDN.
ordernumberThe layout order for the element within a flex or grid container. See MDN.
gridAreastringWhen used in a grid layout, specifies the named grid area that the element should be placed in within the grid. See MDN.
gridColumnstringWhen used in a grid layout, specifies the column the element should be placed in within the grid. See MDN.
gridRowstringWhen used in a grid layout, specifies the row the element should be placed in within the grid. See MDN.
gridColumnStartstringWhen used in a grid layout, specifies the starting column to span within the grid. See MDN.
gridColumnEndstringWhen used in a grid layout, specifies the ending column to span within the grid. See MDN.
gridRowStartstringWhen used in a grid layout, specifies the starting row to span within the grid. See MDN.
gridRowEndstringWhen used in a grid layout, specifies the ending row to span within the grid. See MDN.
Spacing
NameTypeDefaultDescription
marginDimensionValueThe margin for all four sides of the element. See MDN.
marginTopDimensionValueThe margin for the top side of the element. See MDN.
marginBottomDimensionValueThe margin for the bottom side of the element. See MDN.
marginStartDimensionValueThe margin for the logical start side of the element, depending on layout direction. See MDN.
marginEndDimensionValueThe margin for the logical end side of an element, depending on layout direction. See MDN.
marginXDimensionValueThe margin for both the left and right sides of the element. See MDN.
marginYDimensionValueThe margin for both the top and bottom sides of the element. See MDN.
Sizing
NameTypeDefaultDescription
widthDimensionValueThe width of the element. See MDN.
minWidthDimensionValueThe minimum width of the element. See MDN.
maxWidthDimensionValueThe maximum width of the element. See MDN.
heightDimensionValueThe height of the element. See MDN.
minHeightDimensionValueThe minimum height of the element. See MDN.
maxHeightDimensionValueThe maximum height of the element. See MDN.
Positioning
NameTypeDefaultDescription
position'static''relative''absolute''fixed''sticky'Specifies how the element is positioned. See MDN.
topDimensionValueThe top position for the element. See MDN.
bottomDimensionValueThe bottom position for the element. See MDN.
leftDimensionValueThe left position for the element. See MDN. Consider using start instead for RTL support.
rightDimensionValueThe right position for the element. See MDN. Consider using start instead for RTL support.
startDimensionValueThe logical start position for the element, depending on layout direction. See MDN.
endDimensionValueThe logical end position for the element, depending on layout direction. See MDN.
zIndexnumberThe stacking order for the element. See MDN.
isHiddenbooleanHides the element.
Accessibility
NameTypeDefaultDescription
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
Advanced
NameTypeDefaultDescription
UNSAFE_classNamestringSets the CSS className for the element. Only use as a last resort. Use style props instead.
UNSAFE_styleCSSPropertiesSets inline style for the element. Only use as a last resort. Use style props instead.

Visual options#


Density#

View guidelines

<Tabs aria-label="Chat log density example" density="compact">
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with John Doe.</Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Jane Doe.</Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Joe Bloggs.</Text>
    </Content>
  </Item>
</Tabs>
<Tabs
  aria-label="Chat log density example"
  density="compact">
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with John Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>
<Tabs
  aria-label="Chat log density example"
  density="compact">
  <Item
    title="John Doe"
    key="item1">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        John Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Jane Doe"
    key="item2">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Joe Bloggs"
    key="item3">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>

Quiet#

View guidelines

<Tabs aria-label="Chat log quiet example" isQuiet>
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with John Doe.</Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Jane Doe.</Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Joe Bloggs.</Text>
    </Content>
  </Item>
</Tabs>
<Tabs aria-label="Chat log quiet example" isQuiet>
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with John Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>
<Tabs
  aria-label="Chat log quiet example"
  isQuiet>
  <Item
    title="John Doe"
    key="item1">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        John Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Jane Doe"
    key="item2">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Joe Bloggs"
    key="item3">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>

Disabled#

View guidelines

<Flex direction="column" rowGap="size-150">
  <Tabs
    aria-label="Chat log single tab disabled example"
    disabledKeys={['item2']}>
    <Item title="John Doe" key="item1">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with John Doe.</Text>
      </Content>
    </Item>
    <Item title="Jane Doe" key="item2">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with Jane Doe.</Text>
      </Content>
    </Item>
    <Item title="Joe Bloggs" key="item3">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with Joe Bloggs.</Text>
      </Content>
    </Item>
  </Tabs>
  <Tabs aria-label="Chat log all tabs disabled example" isDisabled>
    <Item title="John Doe" key="item1">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with John Doe.</Text>
      </Content>
    </Item>
    <Item title="Jane Doe" key="item2">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with Jane Doe.</Text>
      </Content>
    </Item>
    <Item title="Joe Bloggs" key="item3">
      <Content marginTop="size-250" marginStart="size-125">
        <Text>There is no prior chat history with Joe Bloggs.</Text>
      </Content>
    </Item>
  </Tabs>
</Flex>
<Flex direction="column" rowGap="size-150">
  <Tabs
    aria-label="Chat log single tab disabled example"
    disabledKeys={['item2']}>
    <Item title="John Doe" key="item1">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with John Doe.
        </Text>
      </Content>
    </Item>
    <Item title="Jane Doe" key="item2">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with Jane Doe.
        </Text>
      </Content>
    </Item>
    <Item title="Joe Bloggs" key="item3">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with Joe Bloggs.
        </Text>
      </Content>
    </Item>
  </Tabs>
  <Tabs
    aria-label="Chat log all tabs disabled example"
    isDisabled>
    <Item title="John Doe" key="item1">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with John Doe.
        </Text>
      </Content>
    </Item>
    <Item title="Jane Doe" key="item2">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with Jane Doe.
        </Text>
      </Content>
    </Item>
    <Item title="Joe Bloggs" key="item3">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no prior chat history with Joe Bloggs.
        </Text>
      </Content>
    </Item>
  </Tabs>
</Flex>
<Flex
  direction="column"
  rowGap="size-150">
  <Tabs
    aria-label="Chat log single tab disabled example"
    disabledKeys={[
      'item2'
    ]}>
    <Item
      title="John Doe"
      key="item1">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          John Doe.
        </Text>
      </Content>
    </Item>
    <Item
      title="Jane Doe"
      key="item2">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          Jane Doe.
        </Text>
      </Content>
    </Item>
    <Item
      title="Joe Bloggs"
      key="item3">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          Joe Bloggs.
        </Text>
      </Content>
    </Item>
  </Tabs>
  <Tabs
    aria-label="Chat log all tabs disabled example"
    isDisabled>
    <Item
      title="John Doe"
      key="item1">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          John Doe.
        </Text>
      </Content>
    </Item>
    <Item
      title="Jane Doe"
      key="item2">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          Jane Doe.
        </Text>
      </Content>
    </Item>
    <Item
      title="Joe Bloggs"
      key="item3">
      <Content
        marginTop="size-250"
        marginStart="size-125">
        <Text>
          There is no
          prior chat
          history with
          Joe Bloggs.
        </Text>
      </Content>
    </Item>
  </Tabs>
</Flex>

Orientation#

View guidelines

<Tabs aria-label="Chat log orientation example" orientation="vertical">
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with John Doe.</Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Jane Doe.</Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>There is no prior chat history with Joe Bloggs.</Text>
    </Content>
  </Item>
</Tabs>
<Tabs
  aria-label="Chat log orientation example"
  orientation="vertical">
  <Item title="John Doe" key="item1">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with John Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Jane Doe" key="item2">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item title="Joe Bloggs" key="item3">
    <Content marginTop="size-250" marginStart="size-125">
      <Text>
        There is no prior chat history with Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>
<Tabs
  aria-label="Chat log orientation example"
  orientation="vertical">
  <Item
    title="John Doe"
    key="item1">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        John Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Jane Doe"
    key="item2">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Jane Doe.
      </Text>
    </Content>
  </Item>
  <Item
    title="Joe Bloggs"
    key="item3">
    <Content
      marginTop="size-250"
      marginStart="size-125">
      <Text>
        There is no
        prior chat
        history with
        Joe Bloggs.
      </Text>
    </Content>
  </Item>
</Tabs>

Collapse (overflow behavior)#

View guidelines

If there isn't enough horizontal room to render every tab on a single line, the component will collapse all tabs into a Picker. Note that this does not apply to vertical Tabs.

Try the example below to see the above behavior.

function Example() {
  let [collapse, setCollapse] = React.useState(false);

  return (
    <>
      <div
        style={{
          width: collapse ? '150px' : '300px',
          marginBottom: '50px',
          height: '150px',
          maxWidth: '100%'
        }}>
        <Tabs aria-label="Chat log collapse example">
          <Item title="John Doe" key="item1">
            <Content marginTop="size-250" marginStart="size-125">
              <Text>There is no prior chat history with John Doe.</Text>
            </Content>
          </Item>
          <Item title="Jane Doe" key="item2">
            <Content marginTop="size-250" marginStart="size-125">
              <Text>There is no prior chat history with Jane Doe.</Text>
            </Content>
          </Item>
          <Item title="Joe Bloggs" key="item3">
            <Content marginTop="size-250" marginStart="size-125">
              <Text>There is no prior chat history with Joe Bloggs.</Text>
            </Content>
          </Item>
        </Tabs>
      </div>
      <Button
        variant="primary"
        onPress={() => setCollapse((collapse) => !collapse)}>
        Toggle tab container size.
      </Button>
    </>
  );
}
function Example() {
  let [collapse, setCollapse] = React.useState(false);

  return (
    <>
      <div
        style={{
          width: collapse ? '150px' : '300px',
          marginBottom: '50px',
          height: '150px',
          maxWidth: '100%'
        }}>
        <Tabs aria-label="Chat log collapse example">
          <Item title="John Doe" key="item1">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is no prior chat history with John
                Doe.
              </Text>
            </Content>
          </Item>
          <Item title="Jane Doe" key="item2">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is no prior chat history with Jane
                Doe.
              </Text>
            </Content>
          </Item>
          <Item title="Joe Bloggs" key="item3">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is no prior chat history with Joe
                Bloggs.
              </Text>
            </Content>
          </Item>
        </Tabs>
      </div>
      <Button
        variant="primary"
        onPress={() =>
          setCollapse((collapse) => !collapse)
        }>
        Toggle tab container size.
      </Button>
    </>
  );
}
function Example() {
  let [
    collapse,
    setCollapse
  ] = React.useState(
    false
  );

  return (
    <>
      <div
        style={{
          width: collapse
            ? '150px'
            : '300px',
          marginBottom:
            '50px',
          height:
            '150px',
          maxWidth:
            '100%'
        }}>
        <Tabs aria-label="Chat log collapse example">
          <Item
            title="John Doe"
            key="item1">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is
                no prior
                chat
                history
                with John
                Doe.
              </Text>
            </Content>
          </Item>
          <Item
            title="Jane Doe"
            key="item2">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is
                no prior
                chat
                history
                with Jane
                Doe.
              </Text>
            </Content>
          </Item>
          <Item
            title="Joe Bloggs"
            key="item3">
            <Content
              marginTop="size-250"
              marginStart="size-125">
              <Text>
                There is
                no prior
                chat
                history
                with Joe
                Bloggs.
              </Text>
            </Content>
          </Item>
        </Tabs>
      </div>
      <Button
        variant="primary"
        onPress={() =>
          setCollapse(
            (collapse) =>
              !collapse
          )
        }>
        Toggle tab
        container size.
      </Button>
    </>
  );
}