Skip to content

feat: Allow the slider component to be styled #515

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

Closed
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 @@ -234,6 +234,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 @@ -110,6 +110,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 @@ -36,6 +36,7 @@ const SegmentedControl = ({
fontStyle,
activeFontStyle,
appearance,
sliderStyle,
}: SegmentedControlProps): React.Node => {
const colorSchemeHook = useColorScheme();
const colorScheme = appearance || colorSchemeHook;
Expand Down Expand Up @@ -117,6 +118,7 @@ const SegmentedControl = ({
<Animated.View
style={[
styles.slider,
sliderStyle,
{
transform: [{translateX: animation}],
width: segmentWidth - 4,
Expand Down
5 changes: 5 additions & 0 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@ export type SegmentedControlProps = $ReadOnly<{|
* Touchable style properties for Segmented Control Tab
*/
tabStyle?: ViewStyle,

/**
* Style properties for the slider component (Animated.View)
*/
sliderStyle?: ViewStyle,
|}>;