Skip to content

control_button

Stable

A map control button with an icon or your own content, and an active state.

Generated from the component's definition in the library, so it always matches the version this demo runs.

Attribute Type Default Description
id required string — Unique identifier for the control button
map_id required string — ID of the map to add the control to
position string "top-right" Control position: "top-left", "top-right", "bottom-left", "bottom-right". Defaults to "top-right". A new value moves the button to that corner
icon string nil Text icon or emoji to display (if no slot provided). A new value, or new slot content, is shown at once
tooltip string nil Tooltip text shown on hover, also the button's accessible name. A new value applies at once
active boolean nil Whether the button is in active state, for a button that toggles something. Given (true or false), it makes the button a toggle button: the <button> has aria-pressed="true" or aria-pressed="false", as terrain_control's has. Left out (or nil), the button is not a toggle and has no aria-pressed; it looks inactive. An active button gets the maplibregl-ctrl-active class, which maplibrex.css gives a tinted background, kept while the button is hovered or pressed (--maplibrex-control-active-background sets it, and --maplibrex-control-active-hover-background its hover shade). A new value applies at once
class string "" Additional CSS classes to apply to the button. A new value applies at once
global attributes global — Any other HTML attribute, passed on to the component's element.

Slots

  • inner_block Optional.