Skip to content
DocsTemplatesThemesComponentsPlayground
Get started
Type to search
↑↓Navigate↵SelectEscClose
Documentation
Documentation
Changelog
What's New
Guide
Guide
Getting Started
Principles
Styling Components
Theme System
Working with AI
Foundations
All Tokens
Color
Elevation
Icons
Illustrations
Motion
Shape
Spacing
Typography
Libraries
Libraries
@xds/cli
@xds/core
Themes
Themes
Chocolate Theme
Theme: daily
Default Theme
Gothic Theme
Theme: matcha
Neutral Theme
Stone Theme
Components
Components
AppShell
AspectRatio
Avatar
Avatar
AvatarGroup
AvatarGroupOverflow
AvatarStatusDot
Badge
Banner
Blockquote
Breadcrumbs
BreadcrumbItem
Breadcrumbs
Button
Button
ButtonGroup
IconButton
ToggleButton
ToggleButtonGroup
Calendar
Card
Carousel
Chat
ChatComposer
ChatComposerDrawer
ChatComposerInput
ChatComposerTokenElement
ChatDictationButton
ChatLayout
ChatLayoutScrollButton
ChatMessage
ChatMessageBubble
ChatMessageList
ChatMessageMetadata
ChatSendButton
ChatSystemMessage
ChatTokenizedText
ChatToolCalls
Checkbox
CheckboxInput
CheckboxList
CheckboxListItem
CircularProgress
ClickableCard
Code
CodeBlock
Collapsible
Collapsible
CollapsibleGroup
useXDSCollapsible
CommandPalette
CommandPalette
CommandPaletteEmpty
CommandPaletteFooter
CommandPaletteGroup
CommandPaletteInput
CommandPaletteItem
CommandPaletteList
ContextMenu
ContextMenu
ContextMenuItem
DateInput
DateRangeInput
DateTimeInput
Dialog
AlertDialog
Dialog
DialogHeader
useXDSImperativeAlertDialog
useXDSImperativeDialog
Divider
DropdownMenu
DropdownMenu
DropdownMenuItem
EmptyState
Field
Field
FieldLabel
FieldStatus
InputGroup
InputGroupText
FileInput
Heading
HoverCard
HoverCard
useXDSHoverCard
Icon
Item
Kbd
Layout
Center
FormLayout
Grid
GridSpan
HStack
Layout
LayoutContainer
LayoutContent
LayoutFooter
LayoutHeader
LayoutPanel
Section
StackItem
VStack
Lightbox
Link
List
List
ListItem
Markdown
MetadataList
MetadataList
MetadataListItem
MobileNav
MoreMenu
NavHeadingMenu
NavIcon
NumberInput
OverflowList
Pagination
Popover
Popover
useXDSPopover
PowerSearch
ProgressBar
Radio
RadioList
RadioListItem
Resizable
ResizeHandle
useXDSResizable
SegmentedControl
SegmentedControl
SegmentedControlItem
SelectableCard
Selector
MultiSelector
Selector
SelectorOption
SideNav
SideNav
SideNavCollapseButton
SideNavHeading
SideNavItem
SideNavSection
Skeleton
Slider
Spinner
StatusDot
Stepper
Step
Stepper
Switch
Table
BaseTable
Table
TableCell
TableHeaderCell
TableRow
useXDSTableColumnSettings
useXDSTablePagination
useXDSTableSelection
useXDSTableSelectionState
useXDSTableSortable
Tabs
Tab
TabList
TabMenu
Text
TextArea
TextInput
Thumbnail
TimeInput
Timestamp
Toast
Toast
useXDSToast
Token
Tokenizer
Toolbar
Tooltip
Tooltip
useXDSTooltip
TopNav
TopNav
TopNavHeading
TopNavItem
TopNavMegaMenu
TopNavMegaMenuFeaturedCard
TopNavMegaMenuItem
TopNavMenu
TreeList
Typeahead
BaseTypeahead
Typeahead
TypeaheadItem
Utilities
Utilities
LinkProvider
MediaTheme
SyntaxTheme
Theme
useClickableContainer
useEntryAnimation
useFocusTrap
useGridFocus
useImageMode
useInputContainer
useListFocus
useMediaQuery
useOverflow
useScrollLock
useScrollOverflow
useXDSLayer
useXDSStreamingText
Copyright © Meta Platforms, Inc.GitHub Pages | Terms of Use | Privacy Policy
useClickableContainer@xds/core v0.0.14 · useClickableContainer

Usage

Makes a container element clickable while preserving nested interactive element behavior. Solves the "nested interactive elements" problem: when a card is clickable but contains buttons/links, clicking those should NOT trigger the card's action. Detects interactive ancestors between the click target and the container, and ignores text selections. Supports href navigation (including middle-click and Ctrl/Cmd+click for new tabs).
ts
import {useClickableContainer} from '@xds/core/hooks'

Best practices

GuidancePractices
DoAttach both onClick and onMouseUp to the container element for full click handling including middle-click.
DoUse inside XDSClickableCard or XDSSelectableCard for the standard card interaction pattern.
Don'tUse when the entire container is a single interactive element — just use a <button> or <a> directly.

Parameters

ParamTypeDescription
optionsrequired
UseClickableContainerOptionsConfiguration object for the clickable container.
options.containerRefrequired
RefObject<HTMLElement | null>Ref to the outer container element.
options.interactiveRef
RefObject<HTMLElement | null>Ref to the primary interactive element inside (link, button). If no onClick or href is provided, clicks are proxied to this element.
options.onClick
(event: MouseEvent<HTMLElement>) => voidClick handler fired when the container surface (not a nested interactive element) is clicked.
options.href
stringNavigation URL. When provided, clicking the container navigates to this URL.
options.target
stringLink target (e.g., '_blank'). Used with href for navigation behavior.
options.disabled
boolean (default: false)Whether the container is disabled.

Returns

FieldTypeDescription
onClick(event: MouseEvent<HTMLElement>) => voidClick handler to attach to the container element.
onMouseUp(event: MouseEvent<HTMLElement>) => voidMouse up handler to attach to the container (handles middle-click navigation for href).