Skip to content

Commit c98a01c

Browse files
authored
feat: add content style prop (#4697)
1 parent 95c9390 commit c98a01c

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/components/Snackbar.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
8080
* Style for the wrapper of the snackbar
8181
*/
8282
wrapperStyle?: StyleProp<ViewStyle>;
83+
/**
84+
* Style for the content of the snackbar
85+
*/
86+
contentStyle?: StyleProp<ViewStyle>;
8387
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
8488
ref?: React.RefObject<View>;
8589
/**
@@ -152,8 +156,9 @@ const Snackbar = ({
152156
onDismiss,
153157
children,
154158
elevation = 2,
155-
wrapperStyle,
156159
style,
160+
wrapperStyle,
161+
contentStyle,
157162
theme: themeOverrides,
158163
maxFontSizeMultiplier,
159164
rippleColor,
@@ -279,7 +284,7 @@ const Snackbar = ({
279284
}
280285

281286
return (
282-
<View style={styles.content}>
287+
<View style={[styles.content, contentStyle]}>
283288
{/* View is added to allow multiple lines support for Text component as children */}
284289
<View>{children}</View>
285290
</View>

src/components/__tests__/__snapshots__/Snackbar.test.tsx.snap

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ exports[`renders snackbar with Text as a child 1`] = `
6969
>
7070
<View
7171
style={
72-
{
73-
"flex": 1,
74-
"marginHorizontal": 16,
75-
"marginVertical": 14,
76-
}
72+
[
73+
{
74+
"flex": 1,
75+
"marginHorizontal": 16,
76+
"marginVertical": 14,
77+
},
78+
undefined,
79+
]
7780
}
7881
>
7982
<View>
@@ -154,11 +157,14 @@ exports[`renders snackbar with View & Text as a child 1`] = `
154157
>
155158
<View
156159
style={
157-
{
158-
"flex": 1,
159-
"marginHorizontal": 16,
160-
"marginVertical": 14,
161-
}
160+
[
161+
{
162+
"flex": 1,
163+
"marginHorizontal": 16,
164+
"marginVertical": 14,
165+
},
166+
undefined,
167+
]
162168
}
163169
>
164170
<View>

0 commit comments

Comments
 (0)