- Implementation
- Tab Props
- Tab.List Props
- Tab.Panel Props
Common Examples
Basic Tabs
Tabs are used to separate large blocks of content relevant to the user’s current context. Four components are used to makeup Anvil tabs:Tab, Tab.List, Tab.Button, and Tab.Panel.Notes
- There should always be an equal number of
Tab.ButtonandTab.Panelcomponents. - Values in the
controlsprop of eachTab.Buttoncomponent should match theidof the correspondingTab.Panel.
Changing the Default Tab
By default, the content of theTab.Panel associated to the first Tab.Button will be displayed. To change this behavior, supply the index of the Tab.Button that should be displayed first to the defaultIndex of the parent Tab.Controlled Tabs
To control the active tab from outside the component, use theindex and onIndexChange props. This is useful when you need to synchronize the active tab with external state, such as a URL parameter or another UI element.When using
index, you must also provide onIndexChange to keep the active tab in sync when the user interacts with it directly. Without onIndexChange, the tab will appear frozen.React Accessibility
- An Anvil
Tab.Buttoncannot be disabled. - When a
Tab.Buttonhas focus, the left and right arrow keys and enter can be used to navigate tabs.