Skip to main content
useOverlayContentContext
@coinbase/cds-common@9.28.0
A React context and hook for detecting if components are rendered inside overlay containers like modals, drawers, tours, and trays.
import { OverlayContentContext, useOverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext'
Related components

The useOverlayContentContext hook provides information about whether a component is rendered inside various types of overlay containers. This is useful for conditional rendering and styling based on the overlay context.

Basic usage​

Loading...

Real Modal Example​

Click the button below to open a modal and see how the hook behaves inside vs outside:

Loading...

Using the Context Provider​

You can also use the OverlayContentContext directly to provide context values:

Loading...

Conditional Rendering​

Use the hook to conditionally render content based on overlay context:

Loading...

Styling Based on Context​

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.