% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tm_popup.R
\name{tm_popup}
\alias{tm_popup}
\title{Popup specification for interactive maps}
\usage{
tm_popup(
  vars = NA,
  title = NA,
  format = tm_label_format(),
  width = "auto",
  max.height = "25em",
  title.align = "left",
  title.color = NULL,
  label.align = "left",
  label.color = "#888888",
  value.align = "right",
  value.color = NULL,
  css = NULL
)
}
\arguments{
\item{vars}{Names of the data variables that are shown in the popup table.
A (possibly named) character vector; when named, the names are used as
labels in the popup table. Besides a character vector, the following
special values are supported (identical to the former \code{popup.vars}
argument):
\describe{
\item{\code{TRUE}}{show all variables of the shape object;}
\item{\code{FALSE}}{disable popups;}
\item{\code{NA} (default)}{automatic: if visual variables (e.g. \code{fill}) are
used, only those are shown, otherwise all variables of the shape
object are shown.}
}}

\item{title}{Name of the data variable used as the popup title (the bold
header shown above the popup table). This overrules the layer argument
\code{id}, analogous to how \code{hover} overrules \code{id} for hover labels. The
default (\code{NA}) means that the popup title is derived from \code{id} (the former,
and still default, behaviour). A length-one character vector is expected;
a named value is allowed and reserved for future use.}

\item{format}{A list of formatting options for the popup values, the output
of \code{\link[=tm_label_format]{tm_label_format()}}. Only applicable to numeric data variables. If one
list of formatting options is provided, it is applied to all numeric
variables of \code{vars}. A (named) list of lists can also be provided; in that
case, each list of formatting options is applied to the named variable.}

\item{width}{Width of the popup content (view mode). A bare number is
interpreted as pixels (e.g. \code{300} means \code{"300px"}); a character string is
used as-is, so any CSS length is accepted (\code{"300px"}, \code{"20em"}, \code{"50\%"}).
The default \code{"auto"} lets the popup size to its content.}

\item{max.height}{Maximum height of the popup table before it becomes
vertically scrollable (view mode). A bare number is interpreted as \code{em}
(e.g. \code{5} means \code{"5em"}, roughly "show 5 lines"); a character string is
used as-is. Default \code{"25em"}. Use \code{max.height = "none"} (or \code{NA}/\code{Inf}) to
remove the cap, so the popup grows to fit its content and never scrolls.}

\item{title.align, label.align, value.align}{Horizontal alignment of the
popup title (bold header), the variable-name (label) column, and the value
column respectively. Each one of \code{"left"}, \code{"center"}, or \code{"right"}.
Defaults: title \code{"left"}, label \code{"left"}, value \code{"right"}.}

\item{title.color, label.color, value.color}{Text color of the popup title,
the label column, and the value column respectively. \code{NULL} (the default
for title and value) inherits the browser/popup default; \code{label.color}
defaults to \code{"#888888"} (grey).}

\item{css}{Optional free-form CSS, injected verbatim as a \verb{<style>} block in
each popup, for full restyling beyond the arguments above. Target the
semantic classes \code{.tmap-popup} (container), \code{.tmap-popup-table},
\code{.tmap-popup-title}, \code{.tmap-popup-label}, and \code{.tmap-popup-value}. To size
the popup box itself, target the backend's own popup element
(\code{.leaflet-popup-content} in view mode, \code{.maplibregl-popup-content} in
maplibre mode). Default \code{NULL}.}
}
\value{
A \code{tm_popup} object.
}
\description{
\code{tm_popup()} specifies the popups that are shown in interactive (\code{"view"})
mode when a feature is clicked. It is passed to the \code{popup} argument of the
layer functions (\code{\link[=tm_polygons]{tm_polygons()}}, \code{\link[=tm_symbols]{tm_symbols()}}, \code{\link[=tm_lines]{tm_lines()}}, etc.). It
replaces the (now deprecated) layer arguments \code{popup.vars} and \code{popup.format}.
}
\seealso{
\code{\link[=tm_polygons]{tm_polygons()}}, \code{\link[=tm_symbols]{tm_symbols()}}, \code{\link[=tm_lines]{tm_lines()}}
}
