Skip to content

feat: Allow the slider component to be styled #900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ An object container

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

### `sliderStyle`

(Android and Web only) Styles the slider component (Animated.View)
| Type | Required | Platform |
| ------ | -------- | -------- |
| object | No | Android, Web |

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

## Tips and Tricks

### How can I increase the height of the tab ?
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export interface SegmentedControlProps extends ViewProps {
* Touchable style properties for Segmented Control Tab
*/
tabStyle?: ViewStyle;

/**
* Style properties for the Animated.View component
*/
sliderStyle?: ViewStyle;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions js/SegmentedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
appearance,
accessibilityHintSeperator = 'out of',
testIDS,
sliderStyle,
}: SegmentedControlProps): React.Node => {
const colorSchemeHook = useColorScheme();
const colorScheme = appearance || colorSchemeHook;
Expand Down Expand Up @@ -111,13 +112,14 @@
<Animated.View
style={[
styles.slider,
{

Check warning on line 115 in js/SegmentedControl.js

View workflow job for this annotation

GitHub Actions / lint (20)

Inline style: { zIndex: -1 }
transform: [{translateX: animation}],
width: segmentWidth - 4,
zIndex: -1,
backgroundColor:
tintColor || (colorScheme === 'dark' ? '#636366' : 'white'),
},
sliderStyle,
]}
/>
) : null}
Expand Down
4 changes: 4 additions & 0 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ export type SegmentedControlProps = $ReadOnly<{|
* array testID to each segment button
*/
testIDS: $ReadOnlyArray<string>,
/**
* Style properties for the slider component (Animated.View)
*/
sliderStyle?: ViewStyle,
|}>;
Loading