Skip to content

Tabs with many items are wrapped to multiple lines #701

Open

Description

@reakaleek

Describe the bug

When tabs has more items that the width can handle, then the buttons wrap to a new line

Expected behavior

Not sure. Horizontal scroll?

Steps to reproduce

Image

Source: https://docs-v3-preview.elastic.dev/elastic/docs-builder/tree/main/versions/content-patterns#examples

Tooling

  • docs-builder
  • migration tooling
  • I'm not sure

Activity

  1. KOTungseth commented on May 14, 2026

    @KOTungseth
    Contributor

    The industry standard for documentation typically suggests a maximum of 3 to 5 tabs. When docs pages display 6 or more tabs, the cognitive load significantly increases and users stop scanning the content.

    As a best practice, tabs should never wrap to a second line. Wrapping breaks the mental model of a physical folder tab and makes it difficult to distinguish between the tab bar and the content below it. Wrapping tabs is a problem because they eat into the "above the fold" real-time estate, pushing the actual technical instructions further down, and wrapped tabs create a "staircase" effect that distracts the eye from the documentation. When we consider the mobile experience, wrapped tabs become a vertical nightmare.

    Better alternatives we should consider:

    • For 6 or more tabs, keep the top 4 most frequent choices visible and tuck the rest into a dropdown menu labeled "More...". This would maintain a single clean line.
    • For high-density documentation, like code examples for many different languages, we could replace the tab bar with a dropdown. This is the current experience in /guide.
    • All tab content should be equal. As we create tabbed content, writers should be asking themselves if the tabs are truly equal. If we are mixing categories on 5 or more tabs, the content should be rewritten or reformatted.
  2. cotti commented on May 26, 2026

    @cotti
    Contributor

    Triage update — still reproducible on main

    .tabs uses flex flex-wrap overflow-hidden, so many {tab-item} labels wrap to a new row instead of scrolling horizontally. No commit since the issue was filed has touched the wrap/scroll behavior; recent tab work only fixed ID collisions (#2340) and comment parsing (#3255).

    Where it lives

    • Wrapper class: src/Elastic.Documentation.Site/Assets/markdown/tabs.css (line 3, @apply relative mt-4 flex flex-wrap overflow-hidden)
    • Razor templates: src/Elastic.Markdown/Myst/Directives/Tabs/TabSetView.cshtml and TabItemView.cshtml
    • Same pattern (and likely same bug) in src/Elastic.Documentation.Site/Assets/markdown/applies-switch.css

    Why a CSS-only flip won't work

    The radio-pattern markup interleaves input → label → div.tabs-content as siblings inside .tabs, with order-99 w-full on content panels. Flipping .tabs to flex-nowrap; overflow-x: auto would put panels in the same horizontal flow as labels.

    Proposed plan

    1. Restructure the rendering so labels are emitted into a .tabs-nav and panels into .tabs-panels. Keep the radio input id/label for wiring.
    2. CSS: .tabs-nav { @apply flex flex-nowrap overflow-x-auto; }, flex-shrink: 0; white-space: nowrap; on .tabs-label, drop flex-wrap/overflow-hidden from .tabs.
    3. Mirror the change in applies-switch.css.
    4. Add a snapshot/CSS-class assertion test under tests/Elastic.Markdown.Tests/Directives/TabTests.cs.

    Open questions for UX / writers

    • Is horizontal scroll the desired UX, or would an overflow menu / "more" dropdown be preferred? (Original report said "Not sure. Horizontal scroll?")
    • Mobile/touch: native horizontal scroll is fine on touch, but on desktop should we add a visible scroll hint or arrow buttons?
    • Active-tab visibility: if the selected tab is scrolled off-screen, should we auto-scroll the nav so it's visible on selection?
    • Should the same fix apply to applies-switch simultaneously, or is its current wrap behavior intentional?

    AI-assisted analysis from current main.

  3. added
    ai-triaged
    on May 26, 2026
  4. added
    screen width issue
    on May 26, 2026
  5. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-triagedbugscreen width issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions