--- package: "@svenskaspel/ui" version: "4.4.0" document_type: "component-documentation" source: "@svenskaspel/ui/docs/tabs.md" canonical_url: "/components/tabs" usage_source: "src/app/(docs)/components/tabs/page.mdx" --- # Tabs Tabs are used to switch content within a section. ![Tabs](/images/components/tabs/tabs-figma-a7a00.webp) *** ## Usage Use Tabs to allow the user to switch content within a section. For navigation patterns consider using the Tabs menu component. For selecting options within a form setting the Toggle group could be more appropriate choice of component. ### Navigation and content The Tabs component is often used alongside a Tabs menu, at a hierarchically lower level to further organize content. In contrast the Tabs menu component is used for navigation between different pages within a page. ![Navigation and content](/images/components/tabs/tabs-figma-e11d2.webp) A fictional example where Tabs menu and Tabs are used in combination for navigation and organization. ### When to use the tabs component ![When to use the tabs component – 1](/images/components/tabs/tabs-when-to-use-the-tabs-component-1-7321-41386-0.webp) > **Do:** Use tabs for switching within a section. ![When to use the tabs component – 2](/images/components/tabs/tabs-figma-eeee5.webp) > **Don't:** Don’t use the tabs component for navigation patterns where an item link navigates to a separate destination. ![When to use the tabs component – 3](/images/components/tabs/tabs-figma-f07b0.webp) > **Don't:** Don’t use the tabs component for changing configurations in a form setting. ### States Selected, default, hover and pressed states are indicated by the background and text changing colour. ![States](/images/components/tabs/tabs-figma-711b7.webp) 1. Selected 2. Default 3. Hover 4. Pressed *** ## Formatting ### Anatomy The tabs component consists of a configurable number of tabs within a container. ![Anatomy](/images/components/tabs/tabs-figma-5343a.webp) 1. Container 2. Text label 3. Selected label 4. Default label 5. Close button (optional) *** ## Modify ### High emphasis Tabs are available in two emphasis variants: low and high. Use low emphasis as the default variant in most cases. It gives the tab set a clear structure while keeping the visual expression calm. Use high emphasis when the active tab needs more prominence, for example when tabs are used to separate important views or support multiple hierarchical levels in the interface. ![High emphasis – 1](/images/components/tabs/tabs-figma-aab66.webp) Example of a tab set with a more prominent selected tab. ![High emphasis – 2](/images/components/tabs/tabs-figma-a7722.webp) Example of a tab set with a less prominent selected tab. The high emphasis variant can be useful when tabs are used across multiple hierarchical levels and the active tab needs to stand out more clearly. ![High emphasis](/images/components/tabs/tabs-figma-b0dfd.webp) Example of a design with tabs separating content of multiple hierarchical levels. ### Stretched labels The width of the label can either be determined by the length of the text content, or alternatively the labels extend to fill the available horizontal space. ![Stretched labels – 1](/images/components/tabs/tabs-figma-85772.webp) Default ![Stretched labels – 2](/images/components/tabs/tabs-figma-0cd61.webp) Stretched labels ### Label text Text labels should be clear and concise in order to properly guide the user to their desired content. ![Label text – 1](/images/components/tabs/tabs-figma-425d2.webp) > **Do:** Label tabs to clearly indicate what the associated content contains. ![Label text – 2](/images/components/tabs/tabs-figma-22c5f.webp) > **Don't:** Don’t label tabs in a unclear manner. ### Closable labels Labels can be configured to be closable, typically along with the associated content. In this variant a icon button is added to the right edge of the label. In the stretched label variant he label text is adjusted to the left. ![Closable labels](/images/components/tabs/tabs-figma-1cc8c.webp) Example of tabs with closable labels --- # Readme / API # `Tabs` The `Tabs` component is a set of layered sections of content that are displayed one at a time. - **Responsive Scrolling**: Automatically adds scroll buttons when tabs overflow their container. - **Smart Auto-Scroll**: Automatically scrolls the active tab into view on initial load and when clicking tabs. - **Manual Scroll Support**: Respects user manual scrolling without forcing tabs back into view. > **Looking for link-based navigation instead?** `Tabs` renders Base UI tab panels — if you need a `