Skip to content

Add ocs__tabs--fit to the tabs grammar, so a page's main tabs fit one row on a phone - #2085

Closed
svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:feat/ocs-tabs-fit
Closed

svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:feat/ocs-tabs-fit

Conversation

@svaka2000

@svaka2000 svaka2000 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

This adds one modifier to the tabs grammar, ocs__tabs--fit, for a page's main tabs. On a phone, four tabs with icons don't fit on one row, so they wrap onto two. With --fit they share one row, each with its icon above its words, like the tab bar in a phone app.

  • It only changes tabs at 768px and narrower ($breakpoint-mobile). Wider screens keep the usual tabs.
  • It's opt-in, so the tab bars already on the site don't change. You add it to the same element as ocs__tabs: class="ocs__tabs ocs__tabs--fit".
  • Each tab's icon goes straight inside its ocs__tabs-btn, not in a <span>, since the preset themes recolor span text.
  • Five tabs fit too. A label of a few words wraps inside its own tab, so labels should be short, like a phone app's. The selected tab keeps its underline, and keyboard focus still shows.
  • It uses the grammar's spacing variables and sets no colors, so it follows the theme.
  • The grammar README's Tabs section has the class and an example to copy.
  • The first page to use it is the Community demo in Community: a demo members app built from OCS systems #2086. Either one can merge first.

Four tabs on a 390px-wide phone without --fit:

Four tabs on a 390px phone without ocs__tabs--fit, wrapping onto two rows

The same tabs with --fit:

The same four tabs with ocs__tabs--fit, on one row with each icon above its words

Other notes:

  • I checked it at 390 and 360 px wide in Chrome and in WebKit (the engine Safari uses), in the demo's colors and the Sepia, Light and Midnight themes.

How to try it:

  1. Check out feat/ocs-tabs-fit from svaka2000/Pages-JJ and run make.
  2. Make a test page such as navigation/tabs-test.md with layout: post and permalink: /tabs-test/, and paste in the ocs__tabs--fit example from the Tabs section of _sass/open-coding/README.md.
  3. Open http://localhost:4500/tabs-test/ about 390px wide (DevTools' phone view). The four tabs share one row. Take ocs__tabs--fit off and they wrap onto two rows.

@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #2090 with the same commits.

@svaka2000 svaka2000 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant