Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

useOverflowItems

Hooks & Utilities

useOverflowItems React hook in TypeScript

useMediaQueryusePersistedState
Live props
Options
collapseOrder
minVisible0
reserve0px
disabled
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useOverflowItems
Pro

useOverflowItems React hook in TypeScript

v1.1.0·Updated in 1.12.0

A React overflow menu hook (Priority+) that shows what fits in a row and moves the rest into a More menu.

Drag the corner of the panel to make it narrower or wider: actions that no longer fit fold into the More button one by one, and come back as soon as there is room. The breadcrumb collapses from the middle, keeping the first page and the current one. Open More to reach the hidden actions with the keyboard or a tap.

useOverflowItems is a Pro React hook in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add use-overflow-items.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add use-overflow-items

useOverflowItems is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans

Usage

Import useOverflowItems from @/hooks/use-overflow-items.

import { MoreHorizontal } from "lucide-react"
import { Button } from "@/components/ui/button"
import { useOverflowItems } from "@/hooks/use-overflow-items"

const ACTIONS = ["Edit", "Duplicate", "Download PDF", "Send by email", "Archive"]

export function InvoiceActions() {
  const { containerRef, getItemProps, getMoreProps, hiddenIndexes } = useOverflowItems({ count: ACTIONS.length })

  return (
    <div ref={containerRef} className="relative flex min-w-0 items-center gap-2 overflow-hidden">
      {ACTIONS.map((label, i) => (
        <Button key={label} variant="outline" size="sm" className="shrink-0" {...getItemProps(i)}>
          {label}
        </Button>
      ))}
      <Button variant="ghost" size="icon-sm" aria-label={`${hiddenIndexes.length} more actions`} {...getMoreProps()}>
        <MoreHorizontal />
      </Button>
    </div>
  )
}

API

  • count*
    number

    useOverflowItems(options): how many items the row renders. Every item gets getItemProps(index) spread on its outermost element.

  • collapseOrderdefault "end"
    "end" | "start" | "middle" | readonly number[]

    Which items fold first. end: the last one (actions, tabs). start: the first one. middle: from the second item on, keeping the first and last (breadcrumbs). Or explicit indexes, first to fold first.

  • pinned
    readonly number[]

    Indexes that never fold: the primary action, the current page of a breadcrumb.

  • minVisibledefault 0
    number

    Never fold below this many visible items, even if they overflow.

  • reservedefault 0
    number

    Pixels of the row kept free for something you do not measure (a title that must keep its space).

  • gap
    number

    Pixels between items. Default: read from the row's computed column-gap, so gap-2 just works.

  • disableddefault false
    boolean

    Show every item and stop measuring, e.g. below a breakpoint where CSS already switched to another layout.

  • moreAlwaysVisibledefault false
    boolean

    Keep the More trigger on screen even when every item fits, for rows where some entries always live in the menu. getMoreProps() stays visible and its width is always kept free.

  • returns
    { containerRef; getItemProps(index); getMoreProps(); isHidden(index); hiddenIndexes: number[]; overflowing: boolean; measured: boolean }

    containerRef goes on the row (its content width is the budget). Spread getItemProps(i) on each item and getMoreProps() on the More trigger: a folded item stays mounted but invisible, out of the flow, inert and aria-hidden, so it is measured all the time and returns the moment there is room. Render hiddenIndexes in the overflow menu. Items should be shrink-0 and whitespace-nowrap. measured is false on the server and before the first measurement: keep the row overflow-hidden until then.

Parts

  • OverflowCollapseOrder

    type

    "end" | "start" | "middle" | readonly number[]: which items fold first; an array lists indexes in folding order.

  • UseOverflowItemsOptions

    type

    The options object: count, collapseOrder, pinned, minVisible, gap, reserve, disabled and moreAlwaysVisible.

  • OverflowItemProps

    type

    What getItemProps and getMoreProps return: a ref, data attributes, inert, aria-hidden and the hiding style.

  • UseOverflowItemsResult

    type

    The return value: containerRef, getItemProps, getMoreProps, isHidden, hiddenIndexes, overflowing and measured.

Examples

Collapse from the start

collapseOrder="start" keeps the last actions, so Archive and Delete stay in reach.

Keep at least two

minVisible 2 never folds the first two actions, even when they barely fit.

Breadcrumb that folds the middle

collapseOrder="middle" with the current page pinned, like a file path in a narrow column.

Dependencies

No dependencies beyond React.

Files

  • hooks/use-overflow-items.ts

FAQ

Is the useOverflowItems hook free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install useOverflowItems?

Run npx wingo-ui@latest add use-overflow-items. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/use-overflow-items.

See also

ToolbarBreadcrumbDropdown MenuuseScrollEdgeshookuseMediaQueryhook

Used in

Nav TabsTagPage HeaderToolbarBreadcrumb

More React hooks and utilities

usePersistedStatehookuseScrollStatehookuseSelectionhookuseShortcuthookuseStickToBottomhookAI Chatlib
All 36 React hooks and utilities
PrevioususeMediaQueryNext usePersistedState

Invoice

Northwind Tech LLC · $12,480.00

  1. Home
  2. …
  3. Customers
  4. Companies
  5. New York
  6. Northwind Tech LLC
  7. Invoices
  8. #2026-0412

everything fits

Drag the panel's bottom-right corner to resize it.