---
title: "MapboxRain"
description: "Add a rain effect to the map, forwarding options to the Mapbox rain specification."
canonical_url: "https://mapbox.mhaibaraai.cn/en/docs/environment/rain"
---
# MapboxRain

> Add a rain effect to the map, forwarding options to the Mapbox rain specification.

## Introduction

`MapboxRain` calls `setRain` to add a rain effect to the map. The `options` prop is forwarded directly to the Mapbox rain specification (`density`, `intensity`, `color`, etc.). Omit it to use the default rain effect.

> [!NOTE]
> 
> setRain
> 
>  is an experimental Mapbox API that requires a v3 style (such as 
> 
> standard
> 
> ). It may change in future versions.

## Usage

Overlay a rain effect at a tilted view angle:

```vue [RainExample.vue]
<template>
  <div class="h-115 w-full overflow-hidden rounded-(--ui-radius) border border-default">
    <MapboxMap
      :options="{
        style: 'mapbox://styles/mapbox/standard',
        center: [116.391, 39.908],
        zoom: 16,
        pitch: 60
      }"
    >
      <MapboxRain :options="{ density: 0.5, intensity: 1, color: '#a8b3c4' }" />
    </MapboxMap>
  </div>
</template>
```

## API

### Props

```ts
/**
 * Props for the MapboxRain component
 */
interface MapboxRainProps {
  /**
   * 降雨效果选项；缺省 {} 使用默认雨效
   */
  options?: mapboxgl.RainSpecification | undefined;
}
```

## Changelog

See commit history for [src/runtime/components/environment/Rain.vue](https://github.com/mhaibaraai/movk-mapbox/commits/main/src/runtime/components/environment/Rain.vue).


## Sitemap

See the full [sitemap](https://mapbox.mhaibaraai.cn/sitemap.md) for all pages.
