You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `BoxShadowValue` object is taken by the [`boxShadow`](./view-style-props.md#boxshadow) style prop. It is comprised of 2-4 lengths, an optional color, and an optional `inset` boolean. These values collectively define the box shadow's color, position, size, and blurriness.
7
+
8
+
## Example
9
+
10
+
```js
11
+
{
12
+
offsetX:10,
13
+
offsetY:-3,
14
+
blurRadius:'15px',
15
+
spreadDistance:'10px',
16
+
color:'red',
17
+
inset:true,
18
+
}
19
+
```
20
+
21
+
## Keys and values
22
+
23
+
### `offsetX`
24
+
25
+
The offset on the x-axis. This can be positive or negative. A positive value indicates right and negative indicates left.
26
+
27
+
| Type | Optional |
28
+
| ---------------- | -------- |
29
+
| number \| string | No |
30
+
31
+
### `offsetY`
32
+
33
+
The offset on the y-axis. This can be positive or negative. A positive value indicates up and negative indicates down.
34
+
35
+
| Type | Optional |
36
+
| ---------------- | -------- |
37
+
| number \| string | No |
38
+
39
+
### `blurRadius`
40
+
41
+
Represents the radius used in the [Guassian blur](https://en.wikipedia.org/wiki/Gaussian_blur) algorithm. The larger the value the blurrier the shadow is. Only non-negative values are valid. The default is 0.
42
+
43
+
| Type | Optional |
44
+
| --------------- | -------- |
45
+
| numer \| string | Yes |
46
+
47
+
### `spreadDistance`
48
+
49
+
How much larger or smaller the shadow grows or shrinks. A positive value will grow the shadow, a negative value will shrink the shadow.
50
+
51
+
| Type | Optional |
52
+
| --------------- | -------- |
53
+
| numer \| string | Yes |
54
+
55
+
### `color`
56
+
57
+
The color of the shadow. The default is `black`.
58
+
59
+
| Type | Optional |
60
+
| -------------------- | -------- |
61
+
|[color](./colors.md)| Yes |
62
+
63
+
### `inset`
64
+
65
+
Whether the shadow is inset or not. Inset shadows will appear around the inside of the element's border box as opposed to the outside.
Copy file name to clipboardExpand all lines: docs/shadow-props.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,8 +218,32 @@ export default App;
218
218
219
219
# Reference
220
220
221
+
There are 3 sets of shadow APIs in React Native:
222
+
223
+
-`boxShadow`: A View style prop and a spec-compliant implementation of the [web style prop of the same name](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow).
224
+
-`dropShadow`: A specific filter function available as part of the [`filter`](./view-style-props#filter) View style prop.
225
+
- Various `shadow` props (`shadowColor`, `shadowOffset`, `shadowOpacity`, `shadowRadius`): These map directly to their native counterparts exposed by the platform-level APIs.
226
+
227
+
The difference between `dropShadow` and `boxShadow` are as follows:
228
+
229
+
-`dropShadow` exists as part of `filter`, whereas `boxShadow` is a standalone style prop.
230
+
-`dropShadow` is an alpha mask, so only pixels with a positive alpha value will "cast" a shadow. `boxShadow` will cast around the border box of the element no matter it's contents (unless it is inset).
231
+
-`dropShadow` is only available on Android, `boxShadow` is available on iOS and Android.
232
+
-`dropShadow` cannot be inset like `boxShadow`.
233
+
-`dropShadow` does not have the `spreadDistance` argument like `boxShadow`.
234
+
235
+
Both `boxShadow` and `dropShadow` are generally more capable than the `shadow` props. The `shadow` props, however, map to native platform-level APIs, so if you only need a straightforward shadow these props are recommended. Note that only `shadowColor` works on both Android and iOS, all other `shadow` props only work on iOS.
236
+
221
237
## Props
222
238
239
+
### `boxShadow`
240
+
241
+
See [View Style Props](./view-style-props#boxshadow) for documentation.
Copy file name to clipboardExpand all lines: docs/view-style-props.md
+24-6Lines changed: 24 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -289,6 +289,21 @@ If the rounded border is not visible, try applying `overflow: 'hidden'` as well.
289
289
| ------ |
290
290
| number |
291
291
292
+
### `boxShadow`
293
+
294
+
:::note
295
+
`boxShadow` is only available on the [New Architecture](/architecture/landing-page). Outset shadows are only supported on **Android 9+**. Inset shadows are only supported on **Android 10+**.
296
+
:::
297
+
298
+
Adds a shadow effect to an element, with the ability to control the position, color, size, and blurriness of the shadow. This shadow either appears around the outside or inside of the border box of the element, depending on whether or not the shadow is _inset_. This is a spec-compliant implementation of the [web style prop of the same name](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow). Read more about all the arguments available in the [BoxShadowValue](./boxshadowvalue) documentation.
299
+
300
+
These shadows can be composed together so that a single `boxShadow` can be comprised of multiple different shadows.
301
+
302
+
`boxShadow` takes either a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#syntax) or an array of [BoxShadowValue](./boxshadowvalue) objects.
303
+
| Type |
304
+
| --------------------------- |
305
+
| array of BoxShadowValue ojects \| string |
306
+
292
307
### `cursor` <divclass="label ios">iOS</div>
293
308
294
309
On iOS 17+, Setting to `pointer` allows hover effects when a pointer (such as a trackpad or stylus on iOS, or the users' gaze on visionOS) is over the view.
@@ -311,6 +326,10 @@ Sets the elevation of a view, using Android's underlying [elevation API](https:/
311
326
312
327
### `filter`
313
328
329
+
:::note
330
+
`filter` is only available on the [New Architecture](/architecture/landing-page)
331
+
:::
332
+
314
333
Adds a graphical filter to the `View`. This filter is comprised of any number of _filter functions_, which each represent some atomic change to the graphical composition of the `View`. The complete list of valid filter functions is defined below. `filter` will apply to descendants of the `View` as well as the `View` itself. `filter` implies `overflow: hidden`, so descendants will be clipped to fit the bounds of the `View`.
315
334
316
335
The following filter functions work across all platforms:
@@ -329,18 +348,17 @@ The following filter functions work on Android only:
329
348
-`blur`: Blurs the `View` with a [Guassian blur](https://en.wikipedia.org/wiki/Gaussian_blur), where the specified length represents the radius used in the blurring algorithm. Any non-negative DIP value is valid (no percents). The larger the value, the blurrier the result.
330
349
-`contrast`: Changes the contrast of the `View`. Takes a non-negative number or percentage.
331
350
-`dropShadow`: Adds a shadow around the alpha mask of the `View` (only non-zero alpha pixels in the `View` will cast a shadow). Takes an optional color representing the shadow color, and 2 or 3 lengths. If 2 lengths are specified they are interperted as `offsetX` and `offsetY` which will translate the shadow in the X and Y dimensions respectfully. If a 3rd length is given it is interpreted as the standard deviation of the Guassian blur used on the shadow - so a larger value will blur the shadow more. Read more about the arguments in [DropShadowValue](./dropshadowvalue.md).
332
-
333
-
:::note
334
-
Outset shadows are only supported on **Android 9+**. Inset shadows are only supported on **Android 10+**.
335
-
:::
336
-
337
351
-`grayscale`: Converts the `View` to [grayscale](https://en.wikipedia.org/wiki/Grayscale) by the specified amount. Takes a non-negative number or percentage, where `1` or `100%` represents complete grayscale.
338
352
-`hueRotate`: Changes the [hue](https://en.wikipedia.org/wiki/Hue) of the View. The argument of this function defines the angle of a color wheel around which the hue will be rotated, so e.g., `360deg` would have no effect. This angle can have either `deg` or `rad` units.
339
353
-`invert`: Inverts the colors in the `View`. Takes a non-negative number or percentage, where `1` or `100%` represents complete inversion.
340
354
-`sepia`: Converts the `View` to [sepia](<https://en.wikipedia.org/wiki/Sepia_(color)>). Takes a non-negative number or percentage, where `1` or `100%` represents complete sepia.
341
355
-`saturate`: Changes the [saturation](https://en.wikipedia.org/wiki/Colorfulness) of the `View`. Takes a non-negative number or percentage.
342
356
343
-
`filter` takes either an array of objects comprising of the above filter functions or a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/filter).
357
+
:::note
358
+
`blur` and `dropShadow` are only supported on **Android 12+**
359
+
:::
360
+
361
+
`filter` takes either an array of objects comprising of the above filter functions or a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/filter#syntax).
The `BoxShadowValue` object is taken by the [`boxShadow`](./view-style-props.md#boxshadow) style prop. It is comprised of 2-4 lengths, an optional color, and an optional `inset` boolean. These values collectively define the box shadow's color, position, size, and blurriness.
7
+
8
+
## Example
9
+
10
+
```js
11
+
{
12
+
offsetX:10,
13
+
offsetY:-3,
14
+
blurRadius:'15px',
15
+
spreadDistance:'10px',
16
+
color:'red',
17
+
inset:true,
18
+
}
19
+
```
20
+
21
+
## Keys and values
22
+
23
+
### `offsetX`
24
+
25
+
The offset on the x-axis. This can be positive or negative. A positive value indicates right and negative indicates left.
26
+
27
+
| Type | Optional |
28
+
| ---------------- | -------- |
29
+
| number \| string | No |
30
+
31
+
### `offsetY`
32
+
33
+
The offset on the y-axis. This can be positive or negative. A positive value indicates up and negative indicates down.
34
+
35
+
| Type | Optional |
36
+
| ---------------- | -------- |
37
+
| number \| string | No |
38
+
39
+
### `blurRadius`
40
+
41
+
Represents the radius used in the [Guassian blur](https://en.wikipedia.org/wiki/Gaussian_blur) algorithm. The larger the value the blurrier the shadow is. Only non-negative values are valid. The default is 0.
42
+
43
+
| Type | Optional |
44
+
| --------------- | -------- |
45
+
| numer \| string | Yes |
46
+
47
+
### `spreadDistance`
48
+
49
+
How much larger or smaller the shadow grows or shrinks. A positive value will grow the shadow, a negative value will shrink the shadow.
50
+
51
+
| Type | Optional |
52
+
| --------------- | -------- |
53
+
| numer \| string | Yes |
54
+
55
+
### `color`
56
+
57
+
The color of the shadow. The default is `black`.
58
+
59
+
| Type | Optional |
60
+
| -------------------- | -------- |
61
+
|[color](./colors.md)| Yes |
62
+
63
+
### `inset`
64
+
65
+
Whether the shadow is inset or not. Inset shadows will appear around the inside of the element's border box as opposed to the outside.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.76/shadow-props.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,8 +218,32 @@ export default App;
218
218
219
219
# Reference
220
220
221
+
There are 3 sets of shadow APIs in React Native:
222
+
223
+
-`boxShadow`: A View style prop and a spec-compliant implementation of the [web style prop of the same name](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow).
224
+
-`dropShadow`: A specific filter function available as part of the [`filter`](./view-style-props#filter) View style prop.
225
+
- Various `shadow` props (`shadowColor`, `shadowOffset`, `shadowOpacity`, `shadowRadius`): These map directly to their native counterparts exposed by the platform-level APIs.
226
+
227
+
The difference between `dropShadow` and `boxShadow` are as follows:
228
+
229
+
-`dropShadow` exists as part of `filter`, whereas `boxShadow` is a standalone style prop.
230
+
-`dropShadow` is an alpha mask, so only pixels with a positive alpha value will "cast" a shadow. `boxShadow` will cast around the border box of the element no matter it's contents (unless it is inset).
231
+
-`dropShadow` is only available on Android, `boxShadow` is available on iOS and Android.
232
+
-`dropShadow` cannot be inset like `boxShadow`.
233
+
-`dropShadow` does not have the `spreadDistance` argument like `boxShadow`.
234
+
235
+
Both `boxShadow` and `dropShadow` are generally more capable than the `shadow` props. The `shadow` props, however, map to native platform-level APIs, so if you only need a straightforward shadow these props are recommended. Note that only `shadowColor` works on both Android and iOS, all other `shadow` props only work on iOS.
236
+
221
237
## Props
222
238
239
+
### `boxShadow`
240
+
241
+
See [View Style Props](./view-style-props#boxshadow) for documentation.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.76/view-style-props.md
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -289,6 +289,21 @@ If the rounded border is not visible, try applying `overflow: 'hidden'` as well.
289
289
| ------ |
290
290
| number |
291
291
292
+
### `boxShadow`
293
+
294
+
:::note
295
+
`boxShadow` is only available on the [New Architecture](/architecture/landing-page). Outset shadows are only supported on **Android 9+**. Inset shadows are only supported on **Android 10+**.
296
+
:::
297
+
298
+
Adds a shadow effect to an element, with the ability to control the position, color, size, and blurriness of the shadow. This shadow either appears around the outside or inside of the border box of the element, depending on whether or not the shadow is _inset_. This is a spec-compliant implementation of the [web style prop of the same name](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow). Read more about all the arguments available in the [BoxShadowValue](./boxshadowvalue) documentation.
299
+
300
+
These shadows can be composed together so that a single `boxShadow` can be comprised of multiple different shadows.
301
+
302
+
`boxShadow` takes either a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow#syntax) or an array of [BoxShadowValue](./boxshadowvalue) objects.
303
+
| Type |
304
+
| --------------------------- |
305
+
| array of BoxShadowValue ojects \| string |
306
+
292
307
### `cursor` <divclass="label ios">iOS</div>
293
308
294
309
On iOS 17+, Setting to `pointer` allows hover effects when a pointer (such as a trackpad or stylus on iOS, or the users' gaze on visionOS) is over the view.
@@ -311,6 +326,10 @@ Sets the elevation of a view, using Android's underlying [elevation API](https:/
311
326
312
327
### `filter`
313
328
329
+
:::note
330
+
`filter` is only available on the [New Architecture](/architecture/landing-page)
331
+
:::
332
+
314
333
Adds a graphical filter to the `View`. This filter is comprised of any number of _filter functions_, which each represent some atomic change to the graphical composition of the `View`. The complete list of valid filter functions is defined below. `filter` will apply to descendants of the `View` as well as the `View` itself. `filter` implies `overflow: hidden`, so descendants will be clipped to fit the bounds of the `View`.
315
334
316
335
The following filter functions work across all platforms:
@@ -328,19 +347,18 @@ The following filter functions work on Android only:
328
347
329
348
-`blur`: Blurs the `View` with a [Guassian blur](https://en.wikipedia.org/wiki/Gaussian_blur), where the specified length represents the radius used in the blurring algorithm. Any non-negative DIP value is valid (no percents). The larger the value, the blurrier the result.
330
349
-`contrast`: Changes the contrast of the `View`. Takes a non-negative number or percentage.
331
-
-`dropShadow`: Adds a shadow around the alpha mask of the `View` (only non-zero alpha pixels in the `View` will cast a shadow). Takes an optional color representing the shadow color, and 2 or 3 lengths. If 2 lengths are specified they are interperted as `offsetX` and `offsetY` which will translate the shadow in the X and Y dimensions respectfully. If a 3rd length is given it is interpreted as the standard deviation of the Guassian blur used on the shadow - so a larger value will blur the shadow more. Read more about the arguments in [DropShadowValue](./dropshadowvalue).
332
-
333
-
:::note
334
-
Outset shadows are only supported on **Android 9+**. Inset shadows are only supported on **Android 10+**.
335
-
:::
336
-
350
+
-`dropShadow`: Adds a shadow around the alpha mask of the `View` (only non-zero alpha pixels in the `View` will cast a shadow). Takes an optional color representing the shadow color, and 2 or 3 lengths. If 2 lengths are specified they are interperted as `offsetX` and `offsetY` which will translate the shadow in the X and Y dimensions respectfully. If a 3rd length is given it is interpreted as the standard deviation of the Guassian blur used on the shadow - so a larger value will blur the shadow more. Read more about the arguments in [DropShadowValue](./dropshadowvalue.md).
337
351
-`grayscale`: Converts the `View` to [grayscale](https://en.wikipedia.org/wiki/Grayscale) by the specified amount. Takes a non-negative number or percentage, where `1` or `100%` represents complete grayscale.
338
352
-`hueRotate`: Changes the [hue](https://en.wikipedia.org/wiki/Hue) of the View. The argument of this function defines the angle of a color wheel around which the hue will be rotated, so e.g., `360deg` would have no effect. This angle can have either `deg` or `rad` units.
339
353
-`invert`: Inverts the colors in the `View`. Takes a non-negative number or percentage, where `1` or `100%` represents complete inversion.
340
354
-`sepia`: Converts the `View` to [sepia](<https://en.wikipedia.org/wiki/Sepia_(color)>). Takes a non-negative number or percentage, where `1` or `100%` represents complete sepia.
341
355
-`saturate`: Changes the [saturation](https://en.wikipedia.org/wiki/Colorfulness) of the `View`. Takes a non-negative number or percentage.
342
356
343
-
`filter` takes either an array of objects comprising of the above filter functions or a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/filter).
357
+
:::note
358
+
`blur` and `dropShadow` are only supported on **Android 12+**
359
+
:::
360
+
361
+
`filter` takes either an array of objects comprising of the above filter functions or a string which mimics the [web syntax](https://developer.mozilla.org/en-US/docs/Web/CSS/filter#syntax).
0 commit comments