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

useScrollEdges

Hooks & Utilities

useScrollEdges React hook in TypeScript

usePersistedStateuseScrollState
Live props
Options
fade24px
threshold1px
disabled
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useScrollEdges
Free

useScrollEdges React hook in TypeScript

v1.0.0·Added in 1.0.0

A React scroll shadow and fade hook: knows which edges of a scroll container hide more content and fades them with a mask.

Scroll the notification list: the top fades in as content slides under the header, a hairline appears below the title, and the bottom fade melts away as you reach the end. Swipe the category rail sideways: the edges fade the same way and the arrow buttons (on desktop) hide at each end.

useScrollEdges is a free 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-scroll-edges.

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-scroll-edges

Usage

Import useScrollEdges from @/hooks/use-scroll-edges.

import { fadeMaskStyle, useScrollEdges } from "@/hooks/use-scroll-edges"
import { cn } from "@/lib/utils"

export function Notifications({ items }: { items: string[] }) {
  const { ref, edges } = useScrollEdges<HTMLUListElement>()

  return (
    <section className="flex max-h-80 flex-col">
      <h2 className={cn("px-4 py-3 text-[15px] font-semibold", edges.top && "border-b border-foreground/10")}>Notifications</h2>
      <ul ref={ref} style={fadeMaskStyle("y")} className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-4">
        {items.map((item) => (
          <li key={item} className="py-3 text-sm">{item}</li>
        ))}
      </ul>
    </section>
  )
}

API

  • fadedefault 24
    number

    useScrollEdges(options?): the largest fade in px. The hook writes --fade-top, --fade-bottom, --fade-left and --fade-right on the element, each growing with the distance to its edge, so a fade eases out as you reach the end instead of popping.

  • thresholddefault 1
    number

    Distance in px from an edge that still counts as being at it (absorbs sub-pixel scroll positions).

  • disableddefault false
    boolean

    Stops measuring; the fades stay at their last size.

  • returns
    { ref: RefCallback<T>; edges: ScrollEdges; overflow: { x: boolean; y: boolean } }

    ref goes on the scrolling element (a plain overflow div or a Radix ScrollArea viewport). edges says where more content lies ({ top, bottom, left, right }) and overflow whether it scrolls at all; both re-render only when a value flips, never per scroll frame. Handles RTL.

Parts

  • ScrollEdges

    type

    { top: boolean; bottom: boolean; left: boolean; right: boolean }: where more content lies.

  • ScrollAxis

    type

    "x" | "y" | "both", the axis fadeMaskStyle fades.

  • UseScrollEdgesOptions

    type

    The options object: fade, threshold and disabled.

  • UseScrollEdgesResult

    type

    The return value: { ref, edges, overflow }.

  • fadeMaskStyle

    function

    A mask-image style driven by the vars above. Spread it into the same element's style. It needs no background color, so it works on any surface in both themes. Signature: (axis?: "x" | "y" | "both") => CSSProperties.

Examples

Read to the end to accept

edges.bottom keeps the Accept button locked until the reader scrolls to the last line.

Dividers only when needed

The header and footer hairlines appear only while content scrolls under them.

Dependencies

No dependencies beyond React.

Files

  • hooks/use-scroll-edges.ts

FAQ

Is the useScrollEdges hook free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install useScrollEdges?

Run npx wingo-ui@latest add use-scroll-edges. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/use-scroll-edges.json.

See also

Scroll AreauseScrollStatehookuseOverflowItemshookDialoguseMediaQueryhook

Used in

Heatmap calendarSidebarFilter BuilderNav TabsTabsDialogDrawerSheetMarkdownTagPermissions MatrixTable

and 7 more.

More React hooks and utilities

useSelectionhookuseShortcuthookuseStickToBottomhookAI ChatlibChart kitlibCommercelib
All 36 React hooks and utilities
PrevioususePersistedStateNext useScrollState

Notifications9 new

  • Emma Carter sent you a message2 min ago
  • Price drop: iPhone 13, $1,85018 min ago
  • Your package left New Jersey1 hr ago
  • Liam Brooks rated you 5 stars3 hr ago
  • You received $420 in your walletYesterday, 9:14 PM
  • Order #10482 was deliveredYesterday, 4:02 PM
  • Your listing expires in 3 daysSep 22, 2026
  • Sophia Reed: "Is it still available?"Sep 21, 2026
  • 3 new listings in Brooklyn, BikesSep 20, 2026
useScrollEdges({ fade: 24, threshold: 1 })
topbottomleftright