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

useKeyboardInset

Hooks & Utilities

useKeyboardInset React hook in TypeScript

useDebounceuseLocale
Live props
Options
threshold80px
cssVar
disabled
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useKeyboardInset
Pro

useKeyboardInset React hook in TypeScript

v1.0.0·Added in 1.0.0

A React hook for the mobile on-screen keyboard: how much of the screen it covers, so bars pinned to the bottom ride above it.

Open the demo on a phone and tap the message field: as the keyboard slides up, the composer rides on top of it instead of hiding behind it, and the readout shows the covered height with the open flag lit. Close the keyboard and it settles back to the bottom. On a desktop there is no on-screen keyboard, so the inset stays 0px.

useKeyboardInset 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-keyboard-inset, together with the npm package motion.

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-keyboard-inset

useKeyboardInset 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 useKeyboardInset from @/hooks/use-keyboard-inset.

"use client"

import { motion, useTransform } from "motion/react"
import { useKeyboardInset } from "@/hooks/use-keyboard-inset"

export function Composer() {
  const { inset } = useKeyboardInset()
  const y = useTransform(inset, (v) => -v)

  return (
    <motion.form style={{ y }} className="fixed inset-x-0 bottom-0 z-sticky flex gap-2 bg-background p-3 pb-[max(env(safe-area-inset-bottom),12px)]">
      <input aria-label="Message" placeholder="Write a message" enterKeyHint="send" className="h-11 flex-1 rounded-full bg-foreground/5 px-4 text-base" />
    </motion.form>
  )
}

API

  • thresholddefault 80
    number

    useKeyboardInset(options?): px of covered viewport below which it does not count as a keyboard (browser bars resizing, the iOS form accessory alone).

  • cssVardefault ""
    string

    Also writes the inset in px to this CSS variable on <html> (e.g. "--keyboard-inset"), for CSS-only consumers: bottom: var(--keyboard-inset, 0px). Removed on unmount; use one writer per variable.

  • disableddefault false
    boolean

    Stops measuring and reports 0.

  • returns
    { inset: MotionValue<number>; open: boolean }

    inset: the covered height in px, updated as the keyboard animates without re-rendering; lift a bar with style={{ y: useTransform(inset, (v) => -v) }}. open: true while the keyboard is up, re-rendering only when it flips (hide a floating button, drop a tab bar). Both are 0 / false on the server, during hydration, on desktops, while pinch-zoomed and when no text field has focus.

Parts

  • UseKeyboardInsetOptions

    type

    The hook's options: { disabled?: boolean; threshold?: number; cssVar?: string }.

  • KeyboardInset

    type

    The return value: { inset: MotionValue<number>; open: boolean }.

Examples

Hide the tab bar while typing

Uses the open flag to slide a bottom tab bar away when the keyboard comes up.

CSS variable

cssVar writes the inset to <html>, so a sticky Pay button lifts with plain CSS.

Dependencies

motion

Files

  • hooks/use-keyboard-inset.ts

FAQ

Is the useKeyboardInset hook free?

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

How do I install useKeyboardInset?

Run npx wingo-ui@latest add use-keyboard-inset. It also adds the npm package motion. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/use-keyboard-inset.

See also

useScrollStatehookuseMediaQueryhookBottom Tab BarSticky CTA BarChat Thread

Used in

Checkout stepsSticky CTA BarMention InputRich Text EditorTourSettings LayoutChat WidgetPrompt InputFABInbox Page

More React hooks and utilities

useLocalehookuseLongPresshookuseMediaControlshookuseOverflowItemshookusePersistedStatehookuseScrollEdgeshook
All 36 React hooks and utilities

Articles using this component

  • iOS Safari Keyboard Position Fixed: Keep a Composer Visible

    Mobile UI in React · Oct 13, 2026 · 9 min read

  • 100vh Mobile Fix: When to Use dvh, svh or lvh in Tailwind

    Mobile UI in React · Oct 9, 2026 · 11 min read

PrevioususeDebounceNext useLocale
NT
Northwind Tech LLCEthan Walker · online
Hi! Will order #1042 arrive tomorrow?4:31 PM
Yes, with UPS, between 10 AM and 2 PM.4:34 PM
Perfect. Can I pay $1,240 on delivery?4:38 PM
inset 0pxopenthreshold 80