GitHub Primer JS behaviour

PR Timeline

A vertical event rail with octicons in circular bubbles: commits, reviews, comments, force-pushes. The visual heart of every PR conversation.

Documentation

Real scenarios

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

Every PR is just this rail

Unfold the side commits, then write a comment — it lands on the rail with its own bubble, the way every review and push before it did.

Sara wants to merge 3 commits into main from feature/pdf

Sara pushed 3 commits

feature/pdf

a1b2c3d — pick the PDF renderer

feature/pdf

e4f5a6b — stream large reports instead of buffering

feature/pdf

9c8d7e6 — wire the download button to the job queue

Milad approved these changes

Milad approved

The queue wiring looks right — one naming nit inline, the rest is ready to ship.

Sara force-pushed the branch

Enter nothing, nothing happens; the button knows.

The bubble palette

Six event kinds, six tinted circles — the rail reads at a glance because the colours never change jobs.

commit
comment
approved
changes requested
force-pushed
merged

Important props

Important props
Prop Type Default What it does
rail 2px line 'border-muted' The hairline vertical rail behind the bubbles; it hugs the start side in RTL too.
badge 32px circle 'octicon 16' The 32px bubble carrying the event octicon; its colour names the event kind.
condense state 'false' Condensed mode folds side commits under "and 3 more commits".
comment card body 'markdown' Comments sit on the rail with an author/time header and a markdown body.

Snippet

<div class="prt-item">
    <span class="prt-badge" data-kind="commit"><svg>…</svg></span>
    <div class="prt-body">
        <b>Sara committed</b> <time>2 hours ago</time>
        <p>tightened the date filter</p>
    </div>
</div>

<style>
.prt-item { position: relative; display: flex; gap: 12px; padding-block-end: 24px; }
.prt-item::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 15px;
                    inline-size: 2px; background: #d1d9e0; }
.prt-badge { position: relative; z-index: 1; display: grid; place-items: center;
             inline-size: 32px; aspect-ratio: 1; border-radius: 50%;
             background: #ddf4ff; color: #0969da; }
</style>
// resources/js/Pages/Pulls/Conversation.tsx — Inertia owns the PR
// payload; new comments POST and the list reloads.
import { Head, router } from '@inertiajs/react';
import PrTimeline from '@/components/primer/PrTimeline';

export default function PullConversation() {
  return (
    <>
      <Head title="Conversation · PR #412" />
      {/* onComment={(body) => router.post('/pulls/412/comments', { body })} */}
      <PrTimeline />
    </>
  );
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';

export default function PrTimeline() {
  const [comments, setComments] = useState<string[]>([]);
  const [draft, setDraft] = useState('');
  const send = () => {
    if (!draft.trim()) return;
    setComments([...comments, draft.trim()]);
    setDraft('');
  };

  return (
    <div className="prt-card">
      <div className="prt-item">
        <span className="prt-badge" data-kind="commit">●</span>
        <div className="prt-body">
          <b>Elif pushed 3 commits</b> <time>· 2 days ago</time>
          <p><code>a1b2c3d</code> — pick the PDF renderer</p>
        </div>
      </div>
      {comments.map((c, i) => (
        <div className="prt-item" key={i}>
          <span className="prt-badge">💬</span>
          <div className="prt-body"><div className="prt-comment"><p>{c}</p></div></div>
        </div>
      ))}
      <div className="prt-composer">
        <textarea
          value={draft} onChange={(e) => setDraft(e.target.value)}
          placeholder="Leave a comment — it joins the rail above" aria-label="Write a comment"
        />
        <button disabled={!draft.trim()} onClick={send}>Comment</button>
      </div>
      <style>{`
        .prt-item { position: relative; display: flex; gap: 12px; padding-block-end: 24px; }
        .prt-item::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 15px;
                            inline-size: 2px; background: #d1d9e0; }
        .prt-badge { position: relative; z-index: 1; display: grid; place-items: center; inline-size: 32px;
                     aspect-ratio: 1; border-radius: 50%; background: #ddf4ff; color: #0969da; }
      `}</style>
    </div>
  );
}
<!-- PrTimeline.vue -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';

const comments = ref<string[]>([]);
const draft = ref('');
const send = () => {
  if (!draft.value.trim()) return;
  comments.value.push(draft.value.trim());
  draft.value = '';
};
</script>

<template>
  <div class="prt-card">
    <div class="prt-item">
      <span class="prt-badge" data-kind="commit">●</span>
      <div class="prt-body">
        <b>Elif pushed 3 commits</b> <time>· 2 days ago</time>
        <p><code>a1b2c3d</code> — pick the PDF renderer</p>
      </div>
    </div>
    <div v-for="(c, i) in comments" :key="i" class="prt-item">
      <span class="prt-badge">💬</span>
      <div class="prt-body"><div class="prt-comment"><p>{{ c }}</p></div></div>
    </div>
    <div class="prt-composer">
      <textarea v-model="draft" placeholder="Leave a comment — it joins the rail above" aria-label="Write a comment" />
      <button :disabled="!draft.trim()" @click="send">Comment</button>
    </div>
  </div>
</template>

<style scoped>
.prt-item { position: relative; display: flex; gap: 12px; padding-block-end: 24px; }
.prt-item::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 15px;
                    inline-size: 2px; background: #d1d9e0; }
.prt-badge { position: relative; z-index: 1; display: grid; place-items: center; inline-size: 32px;
             aspect-ratio: 1; border-radius: 50%; background: #ddf4ff; color: #0969da; }
</style>
<!-- PrTimeline.svelte -->
<script lang="ts">
  import '@nabuxai/ui-core/css';

  let comments = $state<string[]>([]);
  let draft = $state('');
  const send = () => {
    if (!draft.trim()) return;
    comments.push(draft.trim());
    draft = '';
  };
</script>

<div class="prt-card">
  <div class="prt-item">
    <span class="prt-badge" data-kind="commit">●</span>
    <div class="prt-body">
      <b>Elif pushed 3 commits</b> <time>· 2 days ago</time>
      <p><code>a1b2c3d</code> — pick the PDF renderer</p>
    </div>
  </div>
  {#each comments as c, i (i)}
    <div class="prt-item">
      <span class="prt-badge">💬</span>
      <div class="prt-body"><div class="prt-comment"><p>{c}</p></div></div>
    </div>
  {/each}
  <div class="prt-composer">
    <textarea bind:value={draft} placeholder="Leave a comment — it joins the rail above" aria-label="Write a comment"></textarea>
    <button disabled={!draft.trim()} onclick={send}>Comment</button>
  </div>
</div>

<style>
.prt-item { position: relative; display: flex; gap: 12px; padding-block-end: 24px; }
.prt-item::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 15px;
                    inline-size: 2px; background: #d1d9e0; }
.prt-badge { position: relative; z-index: 1; display: grid; place-items: center; inline-size: 32px;
             aspect-ratio: 1; border-radius: 50%; background: #ddf4ff; color: #0969da; }
</style>