Skip to main content

StyleImport

Use StyleImport to set configuration options on the Mapbox Standard style. V11 only. The Mapbox Standard style is a new default style that provides a clean, modern basemap with extensive configuration options. StyleImport allows you to customize various aspects of this style, such as the color scheme, font, and lighting.

Import

import { StyleImport } from '@rnmapbox/maps';

Basic Usage

import { MapView, StyleImport } from '@rnmapbox/maps';

function MyMap() {
  return (
    <MapView
      style={{ flex: 1 }}
      styleURL="mapbox://styles/mapbox/standard"
    >
      <StyleImport
        id="basemap"
        existing={true}
        config={{
          colorScheme: "dark",
          font: "Montserrat",
        }}
      />
    </MapView>
  );
}

Props

id

id
string
required
ID of the style import. For the Mapbox Standard style, this is typically "basemap".
<StyleImport id="basemap" existing={true} config={{}} />

existing

existing
boolean
required
Must always be set to true. This indicates that you’re modifying an existing style import rather than creating a new one.
<StyleImport id="basemap" existing={true} config={{}} />

config

config
{ [key: string]: string }
required
A dictionary of configuration options for the style import. The available options depend on the style being imported.For the Mapbox Standard style, common configuration options include:
  • colorScheme - The color scheme: "light", "dark", "dusk", or "dawn"
  • font - The font family for labels
  • lightPreset - Lighting preset: "day", "night", "dusk", or "dawn"
  • showPlaceLabels - Show or hide place labels: "true" or "false"
  • showRoadLabels - Show or hide road labels: "true" or "false"
  • showPointOfInterestLabels - Show or hide POI labels: "true" or "false"
  • showTransitLabels - Show or hide transit labels: "true" or "false"
<StyleImport
  id="basemap"
  existing={true}
  config={{
    colorScheme: "dark",
    font: "Montserrat",
    lightPreset: "night",
    showPlaceLabels: "true",
    showRoadLabels: "true",
  }}
/>

Examples

import { MapView, StyleImport, Camera } from '@rnmapbox/maps';

function DarkMap() {
  return (
    <MapView
      style={{ flex: 1 }}
      styleURL="mapbox://styles/mapbox/standard"
    >
      <StyleImport
        id="basemap"
        existing={true}
        config={{
          colorScheme: "dark",
          lightPreset: "night",
        }}
      />
      <Camera
        centerCoordinate={[-74.006, 40.7128]}
        zoomLevel={14}
      />
    </MapView>
  );
}

Additional Resources

  • MapView - The map container
  • Light - Configure lighting for 3D features
  • Atmosphere - Configure atmospheric effects

Build docs developers (and LLMs) love