Navigation
Overflow Tabs
Tabs that fold the extras into a "more" list: a tab picked from the list takes the last visible slot, so the active tab is always on screen.
- tabs
- overflow
- more menu
- responsive
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/tabs-008?lang=en
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "tabs-008" (Overflow Tabs) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/tabs-008.json
Registry item: https://vibeui.ru/r/tabs-008.json
Installs to: components/vibeui/tabs-008.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
Tabs that fold the extras into a "more" list: a tab picked from the list takes the last visible slot, so the active tab is always on screen.
More tabs than fit: some stay in the row, the rest move into a "more" list with a counter. Picking from the list promotes that tab into the visible row and demotes the one it replaces, so the active tab never disappears. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Tabs008 } from "@/components/vibeui/tabs-008"
<Tabs008
visible={3}
moreLabel="More"
items={[
{ id: "summary", label: "Summary", content: "Key figures" },
]}
/>
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-tabs-008-* palette — do not swap it for your theme tokens (bg-popover, text-muted-foreground and the like)
- swapping the last visible slot for the chosen tab: otherwise the active tab vanishes from the row after a pick
- the counter on the "more" button: without it nobody knows whether one tab is hidden or ten
- aria-expanded on the "more" button — it is how a screen reader knows whether the list is open
- the WAI-ARIA tabs markup: role="tablist", role="tab" with aria-selected and aria-controls, role="tabpanel" with aria-labelledby
- the roving tabindex across the visible row: hidden tabs must not enter the tab order
## 6. You may change
- the items array: labels and panel content
- visible — how many tabs stay in the row
- moreLabel — the caption of the hidden-tabs button
- the accent through the accent prop — it colours the underline and the focus rings
## 7. Rules
- The visible count is a number, not a measurement: the component does not compute the real label widths.
- Arrows walk the visible row only: hidden tabs are reached through the "more" button.
- The list closes on a pick and on a second press of the button, but not on an outside click: add that if you need it.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/tabs-008.jsonhttps://vibeui.ru/r/tabs-008.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-tabs-008-*. Клиентский: "use client" ради выбора, открытия списка и подмены видимой вкладки. Видимый ряд — первые visible вкладок, где последнее место отдано вкладке, выбранной из «ещё»; вытесненная уходит в список. Панель одна на все вкладки, её aria-labelledby указывает на активную. Разметка следует паттерну tabs из WAI-ARIA, стрелки ходят по видимому ряду.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
"use client"
import { useRef, useState } from "react"
import type { CSSProperties, KeyboardEvent, ReactNode } from "react"
export type Tabs008Item = {
id: string
label: string
content?: ReactNode
}
export type Tabs008Props = {
items?: Tabs008Item[]
visible?: number
defaultId?: string
moreLabel?: string
accent?: string
className?: string
style?: CSSProperties
}
// Идея компонента: вкладок больше, чем помещается, и лишние уходят в «ещё».
// Главное правило такой свёртки: выбранная вкладка обязана быть видимой, поэтому
// выбранная из списка занимает последнее видимое место, а вытесненная уходит в
// список. Иначе после выбора активная вкладка исчезает, и непонятно, где ты.
const STYLES = `
:where([data-vibeui-block="tabs-008"]){
--vibeui-tabs-008-bg:oklch(1 0 0);
--vibeui-tabs-008-fg:oklch(0.22 0.014 265);
--vibeui-tabs-008-muted:oklch(0.55 0.014 265);
--vibeui-tabs-008-border:oklch(0.91 0.006 265);
--vibeui-tabs-008-hover:oklch(0.55 0.02 265 / 8%);
--vibeui-tabs-008-accent:oklch(0.55 0.2 262);
--vibeui-tabs-008-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="tabs-008"]{
box-sizing:border-box;width:100%;max-width:28rem;padding:0.5rem 0.75rem 0.875rem;
background:var(--vibeui-tabs-008-bg);color:var(--vibeui-tabs-008-fg);
border:1px solid var(--vibeui-tabs-008-border);border-radius:0.875rem;
font-family:var(--vibeui-tabs-008-font);
}
[data-vibeui-block="tabs-008"] [data-part="row"]{
display:flex;align-items:flex-end;gap:0.25rem;
border-bottom:1px solid var(--vibeui-tabs-008-border);
}
[data-vibeui-block="tabs-008"] [data-part="list"]{display:flex;gap:0.25rem;min-width:0}
[data-vibeui-block="tabs-008"] [data-part="tab"]{
position:relative;appearance:none;border:0;background:none;cursor:pointer;
padding:0.5rem 0.5rem 0.625rem;margin-bottom:-1px;
font:inherit;font-size:0.8125rem;font-weight:500;color:var(--vibeui-tabs-008-muted);
white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:8rem;
}
[data-vibeui-block="tabs-008"] [data-part="tab"]:hover{color:var(--vibeui-tabs-008-fg)}
[data-vibeui-block="tabs-008"] [data-part="tab"]:focus-visible{outline:2px solid var(--vibeui-tabs-008-accent);outline-offset:-3px;border-radius:0.375rem}
[data-vibeui-block="tabs-008"] [data-part="tab"][aria-selected="true"]{color:var(--vibeui-tabs-008-fg);font-weight:650}
[data-vibeui-block="tabs-008"] [data-part="tab"][aria-selected="true"]::after{
content:"";position:absolute;left:0.375rem;right:0.375rem;bottom:0;height:2px;
border-radius:2px 2px 0 0;background:var(--vibeui-tabs-008-accent);
}
[data-vibeui-block="tabs-008"] [data-part="slot"]{position:relative;margin-left:auto}
[data-vibeui-block="tabs-008"] [data-part="more"]{
appearance:none;border:0;background:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.375rem;
padding:0.4375rem 0.5rem;margin-bottom:0.125rem;border-radius:0.4375rem;
font:inherit;font-size:0.8125rem;color:var(--vibeui-tabs-008-muted);
}
[data-vibeui-block="tabs-008"] [data-part="more"]:hover{background:var(--vibeui-tabs-008-hover);color:var(--vibeui-tabs-008-fg)}
[data-vibeui-block="tabs-008"] [data-part="more"]:focus-visible{outline:2px solid var(--vibeui-tabs-008-accent);outline-offset:-2px}
[data-vibeui-block="tabs-008"] [data-part="badge"]{
min-width:1.0625rem;padding:0 0.25rem;box-sizing:border-box;border-radius:999px;
background:var(--vibeui-tabs-008-hover);
font-size:0.6875rem;line-height:1.0625rem;text-align:center;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="tabs-008"] [data-part="menu"]{
position:absolute;top:calc(100% + 0.25rem);right:0;z-index:30;
min-width:10rem;margin:0;padding:0.25rem;box-sizing:border-box;list-style:none;
background:var(--vibeui-tabs-008-bg);
border:1px solid var(--vibeui-tabs-008-border);border-radius:0.625rem;
box-shadow:0 18px 36px -20px oklch(0.2 0.03 265 / 45%);
}
[data-vibeui-block="tabs-008"] [data-part="pick"]{
display:block;width:100%;padding:0.4375rem 0.5rem;box-sizing:border-box;
appearance:none;border:0;background:none;cursor:pointer;border-radius:0.4375rem;
font:inherit;font-size:0.8125rem;color:inherit;text-align:left;
}
[data-vibeui-block="tabs-008"] [data-part="pick"]:hover{background:var(--vibeui-tabs-008-hover)}
[data-vibeui-block="tabs-008"] [data-part="pick"]:focus-visible{outline:2px solid var(--vibeui-tabs-008-accent);outline-offset:-2px}
[data-vibeui-block="tabs-008"] [data-part="panel"]{
padding-top:0.875rem;font-size:0.875rem;line-height:1.6;color:var(--vibeui-tabs-008-muted);
}
[data-vibeui-block="tabs-008"] [data-part="panel"]:focus-visible{outline:2px solid var(--vibeui-tabs-008-accent);outline-offset:3px;border-radius:0.5rem}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="tabs-008"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_ITEMS: Tabs008Item[] = [
{ id: "summary", label: "Сводка", content: "Ключевые цифры за период." },
{ id: "sources", label: "Источники", content: "Откуда приходят посетители." },
{ id: "pages", label: "Страницы", content: "Самые посещаемые адреса." },
{
id: "devices",
label: "Устройства",
content: "Доли телефонов и десктопов.",
},
{ id: "geo", label: "География", content: "Города и страны посетителей." },
{ id: "funnels", label: "Воронки", content: "Шаги до целевого действия." },
]
/**
* Вкладки со свёрткой лишних в список «ещё».
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Tabs008({
items = DEFAULT_ITEMS,
visible = 3,
defaultId,
moreLabel = "Ещё",
accent,
className,
style,
}: Tabs008Props) {
const [active, setActive] = useState(defaultId ?? items[0]?.id)
const [promoted, setPromoted] = useState<string | null>(null)
const [open, setOpen] = useState(false)
const listRef = useRef<HTMLDivElement>(null)
const palette = {
...(accent ? { "--vibeui-tabs-008-accent": accent } : null),
...style,
} as CSSProperties
// Видимый ряд: первые visible вкладок, где последнее место отдано вкладке,
// выбранной из списка «ещё». Так активная вкладка всегда на виду.
const head = items.slice(0, visible)
const shown = promoted
? [
...head.slice(0, visible - 1),
items.find((item) => item.id === promoted) ?? head[visible - 1],
]
: head
const rest = items.filter((item) => !shown.includes(item))
const index = Math.max(
0,
shown.findIndex((item) => item.id === active),
)
function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
const keys = ["ArrowLeft", "ArrowRight", "Home", "End"]
if (!keys.includes(event.key)) {
return
}
event.preventDefault()
const last = shown.length - 1
const next =
event.key === "Home"
? 0
: event.key === "End"
? last
: event.key === "ArrowLeft"
? (index - 1 + shown.length) % shown.length
: (index + 1) % shown.length
setActive(shown[next].id)
listRef.current
?.querySelectorAll<HTMLButtonElement>('[data-part="tab"]')
[next]?.focus()
}
const current = items.find((item) => item.id === active) ?? items[0]
return (
<>
<style href="vibeui-tabs-008" precedence="medium">
{STYLES}
</style>
<div data-vibeui-block="tabs-008" className={className} style={palette}>
<div data-part="row">
<div
data-part="list"
role="tablist"
aria-label="Отчёты"
ref={listRef}
onKeyDown={onKeyDown}
>
{shown.map((item) => (
<button
key={item.id}
type="button"
data-part="tab"
role="tab"
id={`vibeui-tabs-008-${item.id}-tab`}
aria-selected={item.id === active}
aria-controls="vibeui-tabs-008-panel"
tabIndex={item.id === active ? 0 : -1}
onClick={() => setActive(item.id)}
>
{item.label}
</button>
))}
</div>
{rest.length > 0 ? (
<span data-part="slot">
<button
type="button"
data-part="more"
aria-haspopup="true"
aria-expanded={open}
onClick={() => setOpen(!open)}
>
{moreLabel}
<span data-part="badge" aria-hidden="true">
{rest.length}
</span>
</button>
{open ? (
<ul data-part="menu" aria-label="Скрытые вкладки">
{rest.map((item) => (
<li key={item.id}>
<button
type="button"
data-part="pick"
onClick={() => {
setPromoted(item.id)
setActive(item.id)
setOpen(false)
}}
>
{item.label}
</button>
</li>
))}
</ul>
) : null}
</span>
) : null}
</div>
{current ? (
<div
data-part="panel"
role="tabpanel"
id="vibeui-tabs-008-panel"
aria-labelledby={`vibeui-tabs-008-${current.id}-tab`}
tabIndex={0}
>
{current.content}
</div>
) : null}
</div>
</>
)
}