Skip to content

Styling data

Labels

Your own text on the map, placed so labels never overlap.

Quick reference

Utility Does Example
label-[<col>] Your own labels from a column, placed by the map so they never overlap; needs a kharita basemap label-[name]
label-['state name']

How labels are placed

Geometry Label sits
Polygons at a point inside each polygon
Points beside the point, never over it
Lines along the line, following its curve

Numbers get thousands separators and sensible decimals: 1200 becomes 1,200 and 50.50 becomes 50.5. Empty values get no label. The map hides labels that would overlap and shows them as you zoom in. Above 5,000 labels kharita warns.

Labels are drawn by the basemap, so they need a kharita basemap (any theme, not light, dark or fiord). They sit above your data and above the basemap's own place names.

kh.map(states, "theme-paper fill-[density] ramp-ylorrd scheme-q5 stroke-white label-[name]",
       legend={"title": "People per km2"})

Along lines

labels-lines

kh.map(major, "basemap-muted stroke-rose-500 width-[rank] width-max-4 label-[name] legend-none")

Label only some features

Add a second layer with the features to label and stroke-transparent or fill-transparent, as the contours page does for index lines.