GitHub Primer
JS behaviour
Label Chip
Fully-rounded hex-colored labels with matching borders and saturated text. GitHub's color-coded taxonomy that makes every repo scannable.
Real scenarios
The component as it is used in a product — not a specimen grid.
Six characters of hex, one identity
Mint a label: type a name, tap a hue swatch and watch the preview pick its matching border and tinted field. Created chips join the taxonomy — and leave with the ✕.
The classic palette
Every GitHub repo speaks in these hues — and even the white «wontfix» chip keeps a visible border. The trailing counter trims the rest of the set.
bug
documentation
enhancement
good first issue
help wanted
wontfix
priority: critical
+6 more
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| hue | color | '#d73a4a' | Any hex colour; the text derives from the same hue. |
| border | alpha | '≈ 40%' | A same-hue border at low alpha — even white labels stay visible. |
| radius | length | '2em' | Full rounding; 20px height, 12px text. |
| group | layout | 'inline · 8px gap' | Labels wrap in a flex row; a +10 more counter trims the rest. |
Snippet
<span class="prl-label" style="--hue: #7057ff">good first issue</span>
<span class="prl-label" style="--hue: #008672">help wanted</span>
<span class="prl-label" style="--hue: #ffffff">wontfix</span>
<style>
.prl-label { display: inline-flex; align-items: center; block-size: 20px;
padding-inline: 7px; border-radius: 2em; font: 500 12px system-ui;
color: color-mix(in srgb, var(--hue) 70%, black);
border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent); }
html[data-theme="dark"] .prl-label {
color: color-mix(in srgb, var(--hue) 80%, white); }
</style>
// resources/js/Pages/Labels/Index.tsx — the labels page mounts the
// React snippet; Create posts through Inertia and reloads props.
import { Head, router } from '@inertiajs/react';
import LabelChips from '@/components/primer/LabelChips';
export default function LabelsIndex() {
return (
<>
<Head title="Labels" />
{/* onCreate={(name, hue) => router.post('/labels', { name, hue })} */}
<LabelChips />
</>
);
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';
const PALETTE = ['#d73a4a', '#0e8a16', '#0075ca', '#a2eeef', '#7057ff', '#ffffff'];
export default function LabelChips() {
const [labels, setLabels] = useState([
{ name: 'bug', hue: '#d73a4a' },
{ name: 'good first issue', hue: '#7057ff' },
{ name: 'help wanted', hue: '#008672' },
]);
const [draft, setDraft] = useState('');
const [hue, setHue] = useState('#d93f0b');
return (
<div style={{ display: 'grid', gap: 12 }}>
<div className="prl-strip">
{labels.map((l) => (
<span key={l.name} className="prl-label" style={{ '--hue': l.hue } as React.CSSProperties}>{l.name}</span>
))}
</div>
<form
style={{ display: 'flex', gap: 8 }}
onSubmit={(e) => {
e.preventDefault();
if (!draft.trim()) return;
setLabels([{ name: draft.trim(), hue }, ...labels]);
setDraft('');
}}
>
<input value={draft} onChange={(e) => setDraft(e.target.value)} placeholder="new label name" aria-label="Label name" />
{PALETTE.map((h) => (
<button
key={h} type="button" aria-pressed={hue === h} aria-label={h}
style={{ background: h, '--hue': h } as React.CSSProperties}
onClick={() => setHue(h)}
/>
))}
<button type="submit">Create label</button>
</form>
<style>{`
.prl-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.prl-label { display: inline-flex; align-items: center; block-size: 20px;
padding-inline: 7px; border-radius: 2em; font: 500 12px system-ui;
color: color-mix(in srgb, var(--hue) 70%, black);
border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent); }
`}</style>
</div>
);
}
<!-- LabelChips.vue -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';
const PALETTE = ['#d73a4a', '#0e8a16', '#0075ca', '#a2eeef', '#7057ff', '#ffffff'];
const labels = ref([
{ name: 'bug', hue: '#d73a4a' },
{ name: 'good first issue', hue: '#7057ff' },
]);
const draft = ref('');
const hue = ref('#d93f0b');
const create = () => {
if (!draft.value.trim()) return;
labels.value.unshift({ name: draft.value.trim(), hue: hue.value });
draft.value = '';
};
</script>
<template>
<div style="display: grid; gap: 12px">
<div class="prl-strip">
<span v-for="l in labels" :key="l.name" class="prl-label" :style="{ '--hue': l.hue }">{{ l.name }}</span>
</div>
<form style="display: flex; gap: 8px" @submit.prevent="create">
<input v-model="draft" placeholder="new label name" aria-label="Label name" />
<button
v-for="h in PALETTE" :key="h" type="button" :aria-pressed="hue === h" :aria-label="h"
:style="{ background: h, '--hue': h }" @click="hue = h"
/>
<button type="submit">Create label</button>
</form>
</div>
</template>
<style scoped>
.prl-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.prl-label { display: inline-flex; align-items: center; block-size: 20px;
padding-inline: 7px; border-radius: 2em; font: 500 12px system-ui;
color: color-mix(in srgb, var(--hue) 70%, black);
border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent); }
</style>
<!-- LabelChips.svelte -->
<script lang="ts">
import '@nabuxai/ui-core/css';
const PALETTE = ['#d73a4a', '#0e8a16', '#0075ca', '#a2eeef', '#7057ff', '#ffffff'];
let labels = $state([
{ name: 'bug', hue: '#d73a4a' },
{ name: 'good first issue', hue: '#7057ff' },
]);
let draft = $state('');
let hue = $state('#d93f0b');
const create = () => {
if (!draft.trim()) return;
labels.unshift({ name: draft.trim(), hue });
draft = '';
};
</script>
<div style="display: grid; gap: 12px">
<div class="prl-strip">
{#each labels as l (l.name)}<span class="prl-label" style:--hue={l.hue}>{l.name}</span>{/each}
</div>
<form style="display: flex; gap: 8px" onsubmit={(e) => { e.preventDefault(); create(); }}>
<input bind:value={draft} placeholder="new label name" aria-label="Label name" />
{#each PALETTE as h (h)}
<button type="button" aria-pressed={hue === h} aria-label={h} style:background={h} style:--hue={h} onclick={() => (hue = h)}></button>
{/each}
<button type="submit">Create label</button>
</form>
</div>
<style>
.prl-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.prl-label { display: inline-flex; align-items: center; block-size: 20px;
padding-inline: 7px; border-radius: 2em; font: 500 12px system-ui;
color: color-mix(in srgb, var(--hue) 70%, black);
border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent); }
</style>