Overflow Menu
The ever-present kebab: borderless flat items snap open beneath a 3-dot button, with the destructive action quarantined at the bottom.
Real scenarios
The component as it is used in a product — not a specimen grid.
The ever-present kebab
Borderless flat items snap open beneath the 3-dot button — rename and share act through the toast, and delete quarantines itself at the bottom of the list in red, then really deletes the row.
All three files are gone — refresh the page to bring them back.
Flipped up, near the edge
Pinned to a card’s bottom corner, the menu anchors upward instead — same flat frame, same red quarantine.
Auto-sends every Sunday at 8:00 to the ops channel.
The whole family
Small, medium and large — the kebab scales with its menu, and the danger row keeps its place at the end.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| flipped | boolean | false | Anchor the menu to the other side with flipped so it never spills past the edge. |
| danger | boolean | false | The destructive item is always the last row, read in red #da1e28. |
| size | string | 'md' | sm, md or lg; the kebab button scales with its menu. |
Snippet
<div class="cbov" data-open="false">
<button class="cbov-btn" aria-expanded="false" aria-label="Options">
<svg viewBox="0 0 24 24"><circle cx="12" cy="5.5" r="1.7"/>…</svg>
</button>
<ul class="cbov-menu" role="menu">
<li role="menuitem">Rename</li>
<li role="menuitem">Download</li>
<li role="menuitem" data-danger>Delete</li>
</ul>
</div>
<style>
.cbov { position: relative; }
.cbov-btn { inline-size: 2rem; aspect-ratio: 1; border: none; background: transparent; cursor: pointer; }
.cbov[data-open='true'] .cbov-btn { background: #e0e0e0; }
.cbov-menu { position: absolute; inset-block-start: calc(100% + 2px); inset-inline-end: 0; min-inline-size: 10rem;
margin: 0; padding: 0; list-style: none; background: #f4f4f4;
box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.cbov[data-open='false'] .cbov-menu { display: none; }
.cbov-menu li { padding: .55rem 1rem; border-block-end: 1px solid #e0e0e0; font: 400 .875rem/1.3 'IBM Plex Sans'; }
.cbov-menu [data-danger] { color: #da1e28; }
</style>
// app/Pages/Files.jsx — Inertia page; renders the React snippet
// below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import FileKebab from '@/components/FileKebab';
export default function Files() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<FileKebab />
</main>
</NabuXUIProvider>
);
}
// FileKebab.jsx — Carbon overflow menu: flat items, destructive row quarantined last
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';
const INITIAL = [
{ id: 1, name: 'sprint-24-metrics.csv', meta: 'Edited today, 14:20', size: '240KB' },
{ id: 2, name: 'onboarding-guide.pdf', meta: 'Uploaded by Lena, Oct 2', size: '1.2MB' },
{ id: 3, name: 'istanbul-launch.key', meta: 'Edited yesterday, 09:48', size: '18KB' },
];
export default function FileKebab() {
const [files, setFiles] = useState(INITIAL);
const [openId, setOpenId] = useState(null);
const [toast, setToast] = useState(null);
const rootRef = useRef(null);
useEffect(() => {
const onKey = (e) => e.key === 'Escape' && setOpenId(null);
const onTap = (e) => { if (!rootRef.current?.contains(e.target)) setOpenId(null); };
window.addEventListener('keydown', onKey);
window.addEventListener('pointerdown', onTap);
return () => {
window.removeEventListener('keydown', onKey);
window.removeEventListener('pointerdown', onTap);
};
}, []);
const say = (msg) => { setToast(msg); setTimeout(() => setToast(null), 6000); };
// Delete really removes the row, then reports through the toast.
const remove = (file) => {
setOpenId(null);
setFiles((f) => f.filter((x) => x.id !== file.id));
say(`Deleted: ${file.name}`);
};
return (
<>
<style>{`
.cbov-list { max-inline-size: 26rem; border-block-end: 1px solid #e0e0e0;
font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
.cbov-file { position: relative; display: flex; align-items: center; gap: .875rem; padding: .75rem 1rem;
border-block-start: 1px solid #e0e0e0; background: #f4f4f4; }
.cbov-file b { display: block; font-weight: 600; }
.cbov-file small { font-size: .75rem; color: #525252; }
.cbov-size { margin-inline-start: auto; font: 400 .75rem/1 'IBM Plex Mono', Menlo, monospace; color: #525252; }
.cbov { position: relative; }
.cbov-btn { display: grid; place-items: center; inline-size: 2rem; aspect-ratio: 1; border: none;
background: transparent; cursor: pointer; }
.cbov[data-open='true'] .cbov-btn { background: #d1d1d1; }
.cbov-menu { position: absolute; inset-block-start: calc(100% + 2px); inset-inline-end: 0; z-index: 6;
min-inline-size: 10rem; margin: 0; padding: 0; list-style: none; background: #f4f4f4;
box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.cbov[data-open='false'] .cbov-menu { display: none; }
.cbov-item { inline-size: 100%; padding: .625rem 1rem; border: none; border-block-end: 1px solid #e0e0e0;
background: transparent; text-align: start; cursor: pointer;
font: 400 .875rem/1.3 'IBM Plex Sans', sans-serif; }
.cbov-item:hover { background: #e8e8e8; }
.cbov-item[data-danger] { color: #da1e28; }
.cbov-toast { margin: .75rem 0 0; padding: .5rem 1rem; background: #f4f4f4;
border-block-start: 2px solid #da1e28; }
`}</style>
<div className="cbov-list" ref={rootRef}>
{files.map((file) => (
<div className="cbov-file" key={file.id}>
<span><b>{file.name}</b><small>{file.meta}</small></span>
<span className="cbov-size">{file.size}</span>
<div className="cbov" data-open={openId === file.id}>
<button type="button" className="cbov-btn" aria-haspopup="menu" aria-expanded={openId === file.id}
aria-label={`Actions for ${file.name}`}
onClick={() => setOpenId(openId === file.id ? null : file.id)}>⋮</button>
<ul className="cbov-menu" role="menu">
<li role="none"><button type="button" role="menuitem" className="cbov-item"
onClick={() => { setOpenId(null); say('Download started'); }}>Download</button></li>
<li role="none"><button type="button" role="menuitem" className="cbov-item"
onClick={() => { setOpenId(null); say('Share link copied'); }}>Share</button></li>
{/* The destructive action stays quarantined at the bottom. */}
<li role="none"><button type="button" role="menuitem" className="cbov-item" data-danger
onClick={() => remove(file)}>Delete</button></li>
</ul>
</div>
</div>
))}
{toast && <p className="cbov-toast" role="status">{toast}</p>}
</div>
</>
);
}
<!-- FileKebab.vue — Carbon overflow menu: flat items, destructive row quarantined last -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
interface FileRow { id: number; name: string; meta: string; size: string }
const files = ref<FileRow[]>([
{ id: 1, name: 'sprint-24-metrics.csv', meta: 'Edited today, 14:20', size: '240KB' },
{ id: 2, name: 'onboarding-guide.pdf', meta: 'Uploaded by Lena, Oct 2', size: '1.2MB' },
{ id: 3, name: 'istanbul-launch.key', meta: 'Edited yesterday, 09:48', size: '18KB' },
]);
const openId = ref<number | null>(null);
const toast = ref<string | null>(null);
const root = ref<HTMLElement | null>(null);
const say = (msg: string) => { toast.value = msg; setTimeout(() => (toast.value = null), 6000); };
// Delete really removes the row, then reports through the toast.
const remove = (file: FileRow) => {
openId.value = null;
files.value = files.value.filter((f) => f.id !== file.id);
say(`Deleted: ${file.name}`);
};
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') openId.value = null; };
const onTap = (e: PointerEvent) => { if (!root.value?.contains(e.target as Node)) openId.value = null; };
onMounted(() => {
window.addEventListener('keydown', onKey);
window.addEventListener('pointerdown', onTap);
});
onBeforeUnmount(() => {
window.removeEventListener('keydown', onKey);
window.removeEventListener('pointerdown', onTap);
});
</script>
<template>
<div ref="root" class="cbov-list">
<div v-for="file in files" :key="file.id" class="cbov-file">
<span><b>{{ file.name }}</b><small>{{ file.meta }}</small></span>
<span class="cbov-size">{{ file.size }}</span>
<div class="cbov" :data-open="openId === file.id">
<button type="button" class="cbov-btn" aria-haspopup="menu" :aria-expanded="openId === file.id"
:aria-label="`Actions for ${file.name}`" @click="openId = openId === file.id ? null : file.id">⋮</button>
<ul class="cbov-menu" role="menu">
<li role="none"><button type="button" role="menuitem" class="cbov-item"
@click="openId = null; say('Download started')">Download</button></li>
<li role="none"><button type="button" role="menuitem" class="cbov-item"
@click="openId = null; say('Share link copied')">Share</button></li>
<!-- The destructive action stays quarantined at the bottom. -->
<li role="none"><button type="button" role="menuitem" class="cbov-item" data-danger
@click="remove(file)">Delete</button></li>
</ul>
</div>
</div>
<p v-if="toast" class="cbov-toast" role="status">{{ toast }}</p>
</div>
</template>
<style scoped>
.cbov-list { max-inline-size: 26rem; border-block-end: 1px solid #e0e0e0;
font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
.cbov-file { position: relative; display: flex; align-items: center; gap: .875rem; padding: .75rem 1rem;
border-block-start: 1px solid #e0e0e0; background: #f4f4f4; }
.cbov-file b { display: block; font-weight: 600; }
.cbov-file small { font-size: .75rem; color: #525252; }
.cbov-size { margin-inline-start: auto; font: 400 .75rem/1 'IBM Plex Mono', Menlo, monospace; color: #525252; }
.cbov { position: relative; }
.cbov-btn { display: grid; place-items: center; inline-size: 2rem; aspect-ratio: 1; border: none;
background: transparent; cursor: pointer; }
.cbov[data-open='true'] .cbov-btn { background: #d1d1d1; }
.cbov-menu { position: absolute; inset-block-start: calc(100% + 2px); inset-inline-end: 0; z-index: 6;
min-inline-size: 10rem; margin: 0; padding: 0; list-style: none; background: #f4f4f4;
box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.cbov[data-open='false'] .cbov-menu { display: none; }
.cbov-item { inline-size: 100%; padding: .625rem 1rem; border: none; border-block-end: 1px solid #e0e0e0;
background: transparent; text-align: start; cursor: pointer;
font: 400 .875rem/1.3 'IBM Plex Sans', sans-serif; }
.cbov-item:hover { background: #e8e8e8; }
.cbov-item[data-danger] { color: #da1e28; }
.cbov-toast { margin: .75rem 0 0; padding: .5rem 1rem; background: #f4f4f4;
border-block-start: 2px solid #da1e28; }
</style>
<!-- FileKebab.svelte — Carbon overflow menu: flat items, destructive row quarantined last -->
<script lang="ts">
import { onMount } from 'svelte';
import '@nabuxai/ui-core/css';
interface FileRow { id: number; name: string; meta: string; size: string }
let files = $state<FileRow[]>([
{ id: 1, name: 'sprint-24-metrics.csv', meta: 'Edited today, 14:20', size: '240KB' },
{ id: 2, name: 'onboarding-guide.pdf', meta: 'Uploaded by Lena, Oct 2', size: '1.2MB' },
{ id: 3, name: 'istanbul-launch.key', meta: 'Edited yesterday, 09:48', size: '18KB' },
]);
let openId = $state<number | null>(null);
let toast = $state<string | null>(null);
let root: HTMLElement;
const say = (msg: string) => { toast = msg; setTimeout(() => (toast = null), 6000); };
// Delete really removes the row, then reports through the toast.
const remove = (file: FileRow) => {
openId = null;
files = files.filter((f) => f.id !== file.id);
say(`Deleted: ${file.name}`);
};
onMount(() => {
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') openId = null; };
const onTap = (e: PointerEvent) => { if (!root.contains(e.target as Node)) openId = null; };
window.addEventListener('keydown', onKey);
window.addEventListener('pointerdown', onTap);
return () => {
window.removeEventListener('keydown', onKey);
window.removeEventListener('pointerdown', onTap);
};
});
</script>
<div bind:this={root} class="cbov-list">
{#each files as file (file.id)}
<div class="cbov-file">
<span><b>{file.name}</b><small>{file.meta}</small></span>
<span class="cbov-size">{file.size}</span>
<div class="cbov" data-open={openId === file.id}>
<button type="button" class="cbov-btn" aria-haspopup="menu" aria-expanded={openId === file.id}
aria-label="Actions for {file.name}"
onclick={() => (openId = openId === file.id ? null : file.id)}>⋮</button>
<ul class="cbov-menu" role="menu">
<li role="none"><button type="button" role="menuitem" class="cbov-item"
onclick={() => { openId = null; say('Download started'); }}>Download</button></li>
<li role="none"><button type="button" role="menuitem" class="cbov-item"
onclick={() => { openId = null; say('Share link copied'); }}>Share</button></li>
<!-- The destructive action stays quarantined at the bottom. -->
<li role="none"><button type="button" role="menuitem" class="cbov-item" data-danger
onclick={() => remove(file)}>Delete</button></li>
</ul>
</div>
</div>
{/each}
{#if toast}<p class="cbov-toast" role="status">{toast}</p>{/if}
</div>
<style>
.cbov-list { max-inline-size: 26rem; border-block-end: 1px solid #e0e0e0;
font: 400 .875rem/1.4 'IBM Plex Sans', sans-serif; }
.cbov-file { position: relative; display: flex; align-items: center; gap: .875rem; padding: .75rem 1rem;
border-block-start: 1px solid #e0e0e0; background: #f4f4f4; }
.cbov-file b { display: block; font-weight: 600; }
.cbov-file small { font-size: .75rem; color: #525252; }
.cbov-size { margin-inline-start: auto; font: 400 .75rem/1 'IBM Plex Mono', Menlo, monospace; color: #525252; }
.cbov { position: relative; }
.cbov-btn { display: grid; place-items: center; inline-size: 2rem; aspect-ratio: 1; border: none;
background: transparent; cursor: pointer; }
.cbov[data-open='true'] .cbov-btn { background: #d1d1d1; }
.cbov-menu { position: absolute; inset-block-start: calc(100% + 2px); inset-inline-end: 0; z-index: 6;
min-inline-size: 10rem; margin: 0; padding: 0; list-style: none; background: #f4f4f4;
box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.cbov[data-open='false'] .cbov-menu { display: none; }
.cbov-item { inline-size: 100%; padding: .625rem 1rem; border: none; border-block-end: 1px solid #e0e0e0;
background: transparent; text-align: start; cursor: pointer;
font: 400 .875rem/1.3 'IBM Plex Sans', sans-serif; }
.cbov-item:hover { background: #e8e8e8; }
.cbov-item[data-danger] { color: #da1e28; }
.cbov-toast { margin: .75rem 0 0; padding: .5rem 1rem; background: #f4f4f4;
border-block-start: 2px solid #da1e28; }
</style>