File tree 4 files changed +35
-1
lines changed
4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,15 @@ An object container
241
241
242
242
Extends [ ViewStyles] ( https://reactnative.dev/docs/view-style-props )
243
243
244
+ ### ` sliderStyle `
245
+
246
+ (Android and Web only) Styles the slider component (Animated.View)
247
+ | Type | Required | Platform |
248
+ | ------ | -------- | -------- |
249
+ | object | No | Android, Web |
250
+
251
+ Extends [ ViewStyles] ( https://reactnative.dev/docs/view-style-props )
252
+
244
253
## Tips and Tricks
245
254
246
255
### How can I increase the height of the tab ?
Original file line number Diff line number Diff line change @@ -111,6 +111,11 @@ export interface SegmentedControlProps extends ViewProps {
111
111
* Touchable style properties for Segmented Control Tab
112
112
*/
113
113
tabStyle ?: ViewStyle ;
114
+
115
+ /**
116
+ * Style properties for the Animated.View component
117
+ */
118
+ sliderStyle ?: ViewStyle ;
114
119
}
115
120
116
121
/**
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ const SegmentedControl = ({
38
38
appearance,
39
39
accessibilityHintSeperator = 'out of' ,
40
40
testIDS,
41
+ sliderStyle,
41
42
} : SegmentedControlProps ) : React . Node => {
42
43
const colorSchemeHook = useColorScheme ( ) ;
43
44
const colorScheme = appearance || colorSchemeHook ;
@@ -100,7 +101,8 @@ const SegmentedControl = ({
100
101
nativeEvent : {
101
102
layout : { width} ,
102
103
} ,
103
- } ) => updateSegmentWidth ( width ) } >
104
+ } ) => updateSegmentWidth ( width ) }
105
+ >
104
106
{ ! backgroundColor && ! tintColor && (
105
107
< SegmentsSeparators
106
108
values = { values . length }
@@ -118,6 +120,7 @@ const SegmentedControl = ({
118
120
backgroundColor :
119
121
tintColor || ( colorScheme === 'dark' ? '#636366' : 'white' ) ,
120
122
} ,
123
+ sliderStyle ,
121
124
] }
122
125
/>
123
126
) : null }
@@ -148,6 +151,20 @@ const SegmentedControl = ({
148
151
) ;
149
152
} ) }
150
153
</ View >
154
+ { selectedIndex != null && segmentWidth ? (
155
+ < Animated . View
156
+ style = { [
157
+ styles . slider ,
158
+ sliderStyle ,
159
+ {
160
+ transform : [ { translateX : animation } ] ,
161
+ width : segmentWidth - 4 ,
162
+ backgroundColor :
163
+ tintColor || ( colorScheme === 'dark' ? '#636366' : 'white' ) ,
164
+ } ,
165
+ ] }
166
+ />
167
+ ) : null }
151
168
</ View >
152
169
) ;
153
170
} ;
Original file line number Diff line number Diff line change @@ -112,4 +112,7 @@ export type SegmentedControlProps = $ReadOnly<{|
112
112
* array testID to each segment button
113
113
*/
114
114
testIDS : $ReadOnlyArray < string > ,
115
+ * Style properties for the slider component ( Animated . View )
116
+ * /
117
+ sliderStyle ?: ViewStyle ,
115
118
| } > ;
You can’t perform that action at this time.
0 commit comments