Custom styling

You can customize the colors, typography, spacing, borders, and corners of these Places UI kit components:
Places UI kit offers a design system approach to visual customization roughly based on Material Design (with some Google-Maps-specific modifications). See Material Design's reference for Color and Typography . By default, the style adheres to the Google Maps visual design language.

The look and feel of the component is customized with the placesMaterialColor
, placesMaterialFont
, placesMaterialShape
, and placesMaterialTheme
structs.
You can customize the following styles:
theme.color.surface
theme.color.outlineDecorative
theme.color.primary
theme.color.onSurface
theme.color.onSurfaceVariant
theme.color.secondaryContainer
theme.color.onSecondaryContainer
theme.color.neutralContainer
theme.color.onNeutralContainer
theme.color.positiveContainer
theme.color.onPositiveContainer
theme.color.positive
theme.color.negative
theme.color.info
theme.measurement.borderWidthButton
theme.font.bodySmall
theme.font.bodyMedium
theme.font.labelMedium
theme.font.labelLarge
theme.font.headlineMedium
theme.font.displaySmall
theme.font.titleSmall
theme.measurement.spacingExtraSmall
theme.measurement.spacingSmall
theme.measurement.spacingMedium
theme.measurement.spacinglarge
theme.measurement.spacingExtraLarge
theme.measurement.spacingTwoExtraLarge
borderWidth
theme.measurement.borderWidthButton
theme.shape.cornerRadius
theme.shape.cornerRadiusButton
theme.shape.cornerRadiusThumbnail
theme.shape.cornerRadiusCollageOuter
theme.shape.cornerRadiusCard
theme.shape.cornerRadiusDialog
attribution.lightModeColor
attribution.darkModeColor
Attribution colors

Google Maps' terms of service require you to use one of three brand colors for the Google Maps attribution. This attribution must be visible and accessible when customization changes have been made.
We offer 3 brand colors to choose from that can be independently set for light and dark themes:
- Light theme:
attributionColorLight
with enums for white, gray, and black. - Dark theme:
attributionColorDark
with enums for white, gray, and black.
Examples
This function creates a theme that overrides the default style attributes. Any theme attributes that are not overridden use the default styles.Swift
// Same for compact and full func makeTemplateTheme ( colorScheme : ColorScheme ) - > PlacesMaterialTheme { var theme = PlacesMaterialTheme () var color = PlacesMaterialColor () color . surface = ( colorScheme == . dark ? . blue : . gray ) color . buttonBorder = ( colorScheme == . dark ? . pink : . orange ) color . outlineDecorative = ( colorScheme == . dark ? . white : . black ) color . onSurface = ( colorScheme == . dark ? . yellow : . red ) color . onSurfaceVariant = ( colorScheme == . dark ? . white : . blue ) color . onSecondaryContainer = ( colorScheme == . dark ? . white : . red ) color . secondaryContainer = ( colorScheme == . dark ? . green : . purple ) color . positive = ( colorScheme == . dark ? . yellow : . red ) color . primary = ( colorScheme == . dark ? . yellow : . purple ) color . info = ( colorScheme == . dark ? . yellow : . purple ) var shape = PlacesMaterialShape () shape . cornerRadius = 10 var font = PlacesMaterialFont () font . labelLarge = . system ( size : UIFontMetrics . default . scaledValue ( for : 18 )) font . headlineMedium = . system ( size : UIFontMetrics . default . scaledValue ( for : 15 )) font . bodyLarge = . system ( size : UIFontMetrics . default . scaledValue ( for : 15 )) font . bodyMedium = . system ( size : UIFontMetrics . default . scaledValue ( for : 12 )) font . bodySmall = . system ( size : UIFontMetrics . default . scaledValue ( for : 11 )) var attribution = PlacesMaterialAttribution () attribution . lightModeColor = . black attribution . darkModeColor = . white theme . measurement . borderWidthButton = 1 theme . color = color theme . shape = shape theme . font = font theme . attribution = attribution return theme }