On this page

Type Alias PopupOptions

The Popup options object

type PopupOptions = {
    anchor?: PositionAnchor;
    className?: string;
    closeButton?: boolean;
    closeOnClick?: boolean;
    closeOnMove?: boolean;
    focusAfterOpen?: boolean;
    locationOccludedOpacity?: number | string;
    maxWidth?: string;
    offset?: Offset;
    padding?: PaddingOptions;
    subpixelPositioning?: boolean;
}
Index

Properties

A string indicating the part of the Popup that should be positioned closest to the coordinate set via Popup.setLngLat. Options are 'center', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', and 'bottom-right'. If unset the anchor will be dynamically set to ensure the popup falls within the map container with a preference for 'bottom'.

className?: string

Space-separated CSS class names to add to popup container

closeButton?: boolean

If true, a close button will appear in the top right corner of the popup.

true
closeOnClick?: boolean

If true, the popup will closed when the map is clicked.

true
closeOnMove?: boolean

If true, the popup will closed when the map moves.

false
focusAfterOpen?: boolean

If true, the popup will try to focus the first focusable element inside the popup.

true
locationOccludedOpacity?: number | string

Optional opacity when the location is behind the globe. Note that if a number is provided, it will be converted to a string.

undefined
maxWidth?: string

A string that sets the CSS property of the popup's maximum width, eg '300px'. To ensure the popup resizes to fit its content, set this property to 'none'. Available values can be found here: https://developer.mozilla.org/en-US/docs/Web/CSS/max-width

'240px'
offset?: Offset

A pixel offset applied to the popup's location

padding?: PaddingOptions

A pixel padding applied to the popup's positioning constraints. The popup will be positioned to avoid being placed within this padding area from the edges of the map container.

undefined
subpixelPositioning?: boolean

If true, rounding is disabled for placement of the popup, allowing for subpixel positioning and smoother movement when the popup is translated.

false
Was this helpful?
SDK JS
Reference
PopupOptions