Skip to content

Commit c913dfc

Browse files
committed
feat: Allow the slider component to be styled
Signed-off-by: Gegham Zakaryan <[email protected]>
1 parent ff2eb3f commit c913dfc

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ An object container
234234

235235
Extends [ViewStyles](https://reactnative.dev/docs/view-style-props)
236236

237+
### `sliderStyle`
238+
239+
(Android and Web only) Styles the slider component (Animated.View)
240+
| Type | Required | Platform |
241+
| ------ | -------- | -------- |
242+
| object | No | Android, Web |
243+
244+
Extends [ViewStyles](https://reactnative.dev/docs/view-style-props)
245+
237246
## Tips and Tricks
238247

239248
### How can I increase the height of the tab ?

index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ export interface SegmentedControlProps extends ViewProps {
110110
* Touchable style properties for Segmented Control Tab
111111
*/
112112
tabStyle?: ViewStyle;
113+
114+
/**
115+
* Style properties for the Animated.View component
116+
*/
117+
sliderStyle?: ViewStyle;
113118
}
114119

115120
/**

js/SegmentedControl.js

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const SegmentedControl = ({
3636
fontStyle,
3737
activeFontStyle,
3838
appearance,
39+
sliderStyle,
3940
}: SegmentedControlProps): React.Node => {
4041
const colorSchemeHook = useColorScheme();
4142
const colorScheme = appearance || colorSchemeHook;
@@ -117,6 +118,7 @@ const SegmentedControl = ({
117118
<Animated.View
118119
style={[
119120
styles.slider,
121+
sliderStyle,
120122
{
121123
transform: [{translateX: animation}],
122124
width: segmentWidth - 4,

js/types.js

+5
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,9 @@ export type SegmentedControlProps = $ReadOnly<{|
107107
* Touchable style properties for Segmented Control Tab
108108
*/
109109
tabStyle?: ViewStyle,
110+
111+
/**
112+
* Style properties for the slider component (Animated.View)
113+
*/
114+
sliderStyle?: ViewStyle,
110115
|}>;

0 commit comments

Comments
 (0)