import { fn } from '@storybook/test';
import { Button, Tooltip, Slot, Fill, SlotFillProvider } from '@wordpress/components';
import { wordpress, more, link } from '@wordpress/icons';
import { useState } from 'react';
import { Tabs } from '..';
import { Icon } from '../../icon';
import type { Meta, StoryFn } from '@storybook/react';
const meta: Meta< typeof Tabs > = {
title: 'Tabs',
id: 'components-tabs',
component: Tabs,
subcomponents: {
'Tabs.TabList': Tabs.TabList,
'Tabs.Tab': Tabs.Tab,
'Tabs.TabPanel': Tabs.TabPanel,
},
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
docs: { canvas: { sourceState: 'shown' } },
},
args: {
onActiveTabIdChange: fn(),
onSelect: fn(),
},
};
export default meta;
const Template: StoryFn< typeof Tabs > = ( props ) => {
return (
Selected tab: Tab 1 Selected tab: Tab 2 Selected tab: Tab 3
This tabpanel has its Selected tab: Tab 1 Selected tab: Tab 2 Selected tab: Tab 3
This tabpanel has its focusable prop set to
false, so it won't get a tab stop.
Instead, the [Tab] key will move focus to the first focusable element within the panel.
focusable prop set to
false, so it won't get a tab stop.
Instead, the [Tab] key will move focus to the first focusable element within the panel.
This story helps understand how the TabList component behaves under different conditions. The container below (with the dotted red border) can be horizontally resized, and it has a bit of padding to be out of the way of the TabList.
The button will toggle between full width (adding width: 100%) and the
default width.
Try the following:
width: 100%
{ ' ' }
set on the TabList (tabs fill up the space).
width: 100%
{ ' ' }
(defaults to auto) set on the TabList (tabs take up space proportional
to their content).
Selected tab: Tab 1
(Label with multiple words)
Selected tab: Tab 2
(Short)
Selected tab: Tab 3
(Hippopotomonstrosesquippedaliophobia)
Selected tab: Tab 4
Selected tab: Tab 5
Selected tab: Tab 1
Selected tab: Tab 2
Selected tab: Tab 3
Selected tab: Tab 1
Selected tab: Tab 2
Selected tab: Tab 3
Selected tab: Tab 1
Selected tab: Tab 2
Selected tab: Tab 3
other stuff
other stuff
this is fun!
other stuff
Selected tab: Tab 1
Selected tab: Tab 2
Selected tab: Tab 3