GitHub Primer JS behaviour

Underline Nav

Conversation/Commits/Checks/Files changed underlined tabs with live CounterLabels. GitHub's signature sub-navigation for issues and PRs.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

Tabs, the GitHub way

Four tabs, four CounterLabels, one burnt-orange underline. Hover a tab for the gray window, click it and the panel beneath obeys.

Merged Milad merged 3 commits into main

The conversation keeps 4 comments, 1 approval and the squash decision — scroll the rail above in the PR Timeline demo.

a1b2c3d pick the PDF renderer
e4f5a6b stream large reports instead of buffering
9c8d7e6 wire the download button to the queue
build & test #812 · 3 min
lint #812 · 41s
e2e / reports #812 · 5 min · flaky, retried
app/Jobs/RenderReportPdf.php+124 −0
resources/views/reports/show.blade.php+18 −4
tests/Feature/ReportPdfTest.php+46 −2

CounterLabel postures

Neutral gray at rest, accent when its tab owns the underline, and the compact density for toolbars — one component, three voices.

neutral
aria-current="page"
compact

Important props

Important props
Prop Type Default What it does
selected underline '2px orange?' The 2px underline on the selected tab; default fg-colour, with a soft gray rounded hover window.
counter CounterLabel 'rounded 2em' The rounded counter at each tab end; the selected one reads bolder.
overflow scroll 'inline' On mobile the tabs glide inline; nothing wraps away.
icon octicon · 16px 'optional' Each tab may carry a 16px octicon before its label.

Snippet

<nav class="prn-nav" aria-label="Pull request page">
    <button class="prn-tab" aria-current="page">
        <svg>…</svg> Conversation <span class="prn-count">4</span>
    </button>
    <button class="prn-tab">
        <svg>…</svg> Commits <span class="prn-count">7</span>
    </button>
</nav>

<style>
.prn-nav { display: flex; gap: 8px; border-block-end: 1px solid #d1d9e0;
           overflow-x: auto; }
.prn-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px;
           border: 0; border-block-end: 2px solid transparent; background: none;
           font: 500 14px system-ui; }
.prn-tab[aria-current='page'] { border-block-end-color: #1f2328; }
.prn-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em;
             background: #eff2f5; font: 500 12px/20px system-ui; }
</style>
// resources/js/Pages/Pulls/Show.tsx — tab changes can sync to the
// URL hash; the tabbed sub-nav is the React snippet.
import { Head } from '@inertiajs/react';
import UnderlineNav from '@/components/primer/UnderlineNav';

export default function PullShow() {
  return (
    <>
      <Head title="PR #412" />
      <UnderlineNav />
    </>
  );
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';

const TABS = [
  { id: 'conversation', label: 'Conversation', count: 4 },
  { id: 'commits', label: 'Commits', count: 7 },
  { id: 'checks', label: 'Checks', count: 3 },
  { id: 'files', label: 'Files changed', count: 12 },
];

export default function UnderlineNav() {
  const [tab, setTab] = useState('conversation');
  const active = TABS.find((t) => t.id === tab)!;

  return (
    <div className="prn-page">
      <nav className="prn-nav" role="tablist" aria-label="Pull request sections">
        {TABS.map((t) => (
          <button
            key={t.id} className="prn-tab" role="tab"
            aria-current={tab === t.id ? 'page' : undefined} onClick={() => setTab(t.id)}
          >
            {t.label} <span className="prn-count">{t.count}</span>
          </button>
        ))}
      </nav>
      <div className="prn-panel" role="tabpanel">{active.count} items on the {active.label.toLowerCase()} tab.</div>
      <style>{`
        .prn-nav { display: flex; gap: 8px; border-block-end: 1px solid #d1d9e0; overflow-x: auto; }
        .prn-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px; border: 0;
                   border-block-end: 2px solid transparent; background: none; font: 500 14px system-ui; }
        .prn-tab[aria-current='page'] { border-block-end-color: #1f2328; }
        .prn-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em;
                     background: #eff2f5; font: 500 12px/20px system-ui; }
      `}</style>
    </div>
  );
}
<!-- UnderlineNav.vue -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';

const TABS = [
  { id: 'conversation', label: 'Conversation', count: 4 },
  { id: 'commits', label: 'Commits', count: 7 },
  { id: 'checks', label: 'Checks', count: 3 },
  { id: 'files', label: 'Files changed', count: 12 },
];
const tab = ref('conversation');
</script>

<template>
  <div class="prn-page">
    <nav class="prn-nav" role="tablist" aria-label="Pull request sections">
      <button
        v-for="t in TABS" :key="t.id" class="prn-tab" role="tab"
        :aria-current="tab === t.id ? 'page' : null" @click="tab = t.id"
      >
        {{ t.label }} <span class="prn-count">{{ t.count }}</span>
      </button>
    </nav>
    <div class="prn-panel" role="tabpanel">
      {{ TABS.find((t) => t.id === tab)?.count }} items on the {{ tab }} tab.
    </div>
  </div>
</template>

<style scoped>
.prn-nav { display: flex; gap: 8px; border-block-end: 1px solid #d1d9e0; overflow-x: auto; }
.prn-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px; border: 0;
           border-block-end: 2px solid transparent; background: none; font: 500 14px system-ui; }
.prn-tab[aria-current='page'] { border-block-end-color: #1f2328; }
.prn-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em;
             background: #eff2f5; font: 500 12px/20px system-ui; }
</style>
<!-- UnderlineNav.svelte -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  const TABS = [
    { id: 'conversation', label: 'Conversation', count: 4 },
    { id: 'commits', label: 'Commits', count: 7 },
    { id: 'checks', label: 'Checks', count: 3 },
    { id: 'files', label: 'Files changed', count: 12 },
  ];
  let tab = $state('conversation');
  const active = $derived(TABS.find((t) => t.id === tab)!);
</script>

<div class="prn-page">
  <nav class="prn-nav" role="tablist" aria-label="Pull request sections">
    {#each TABS as t (t.id)}
      <button
        class="prn-tab" role="tab"
        aria-current={tab === t.id ? 'page' : undefined} onclick={() => (tab = t.id)}
      >
        {t.label} <span class="prn-count">{t.count}</span>
      </button>
    {/each}
  </nav>
  <div class="prn-panel" role="tabpanel">{active.count} items on the {active.label.toLowerCase()} tab.</div>
</div>

<style>
.prn-nav { display: flex; gap: 8px; border-block-end: 1px solid #d1d9e0; overflow-x: auto; }
.prn-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px; border: 0;
           border-block-end: 2px solid transparent; background: none; font: 500 14px system-ui; }
.prn-tab[aria-current='page'] { border-block-end-color: #1f2328; }
.prn-count { min-inline-size: 20px; padding-inline: 6px; border-radius: 2em;
             background: #eff2f5; font: 500 12px/20px system-ui; }
</style>