@@ -23,7 +23,8 @@ import {
23
23
import MenuItem from './MenuItem' ;
24
24
import { APPROX_STATUSBAR_HEIGHT } from '../../constants' ;
25
25
import { withInternalTheme } from '../../core/theming' ;
26
- import type { $Omit , InternalTheme } from '../../types' ;
26
+ import type { $Omit , InternalTheme , MD3Elevation } from '../../types' ;
27
+ import { ElevationLevels } from '../../types' ;
27
28
import { addEventListener } from '../../utils/addEventListener' ;
28
29
import { BackHandler } from '../../utils/BackHandler/BackHandler' ;
29
30
import Portal from '../Portal/Portal' ;
@@ -67,6 +68,11 @@ export type Props = {
67
68
*/
68
69
contentStyle ?: Animated . WithAnimatedValue < StyleProp < ViewStyle > > ;
69
70
style ?: StyleProp < ViewStyle > ;
71
+ /**
72
+ * Elevation level of the menu's content. Shadow styles are calculated based on this value. Default `backgroundColor` is taken from the corresponding `theme.colors.elevation` property. By default equals `2`.
73
+ * @supported Available in v5.x with theme version 3
74
+ */
75
+ elevation ?: MD3Elevation ;
70
76
/**
71
77
* @optional
72
78
*/
@@ -103,6 +109,11 @@ const EASING = Easing.bezier(0.4, 0, 0.2, 1);
103
109
104
110
const WINDOW_LAYOUT = Dimensions . get ( 'window' ) ;
105
111
112
+ const DEFAULT_ELEVATION : MD3Elevation = 2 ;
113
+ const ELEVATION_LEVELS_MAP = Object . values (
114
+ ElevationLevels
115
+ ) as ElevationLevels [ ] ;
116
+
106
117
/**
107
118
* Menus display a list of choices on temporary elevated surfaces. Their placement varies based on the element that opens them.
108
119
*
@@ -406,6 +417,7 @@ class Menu extends React.Component<Props, State> {
406
417
anchorPosition,
407
418
contentStyle,
408
419
style,
420
+ elevation = DEFAULT_ELEVATION ,
409
421
children,
410
422
theme,
411
423
statusBarHeight,
@@ -639,11 +651,12 @@ class Menu extends React.Component<Props, State> {
639
651
styles . shadowMenuContainer ,
640
652
shadowMenuContainerStyle ,
641
653
theme . isV3 && {
642
- backgroundColor : theme . colors . elevation . level2 ,
654
+ backgroundColor :
655
+ theme . colors . elevation [ ELEVATION_LEVELS_MAP [ elevation ] ] ,
643
656
} ,
644
657
contentStyle ,
645
658
] }
646
- { ...( theme . isV3 && { elevation : 2 } ) }
659
+ { ...( theme . isV3 && { elevation } ) }
647
660
testID = { `${ testID } -surface` }
648
661
theme = { theme }
649
662
>
0 commit comments