All Projects → react-native-segmented-control → Segmented Control

react-native-segmented-control / Segmented Control

Licence: mit
React Native SegmentedControl library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Segmented Control

Conference Data
Conference data for www.confs.tech
Stars: ✭ 197 (-1.01%)
Mutual labels:  hacktoberfest
Grank
Github 项目活跃度分析工具
Stars: ✭ 199 (+0%)
Mutual labels:  hacktoberfest
Cucumber Jvm
Cucumber for the JVM
Stars: ✭ 2,363 (+1087.44%)
Mutual labels:  hacktoberfest
Lighthouse Ci
A useful wrapper around Google Lighthouse CLI
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
A Good Readme Template
A template to make good README.md
Stars: ✭ 196 (-1.51%)
Mutual labels:  hacktoberfest
Zeebe Modeler
Desktop Application for modeling Zeebe Workflows with BPMN
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Tenseal
A library for doing homomorphic encryption operations on tensors
Stars: ✭ 197 (-1.01%)
Mutual labels:  hacktoberfest
Windows Terminals
Repository with some awesome Windows Terminals themes
Stars: ✭ 199 (+0%)
Mutual labels:  hacktoberfest
Certificate Transparency Android
Certificate transparency for Android and Java
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Codeigniter Ion Auth
Simple and Lightweight Auth System for CodeIgniter
Stars: ✭ 2,290 (+1050.75%)
Mutual labels:  hacktoberfest
Mattermost Redux
Redux for Mattermost
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Sequenceserver
Intuitive local web frontend for the BLAST bioinformatics tool
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Linkedin Skill Assessments Quizzes
Full reference of LinkedIn answers 2021 for skill assessments, LinkedIn test, questions and answers (aws-lambda, rest-api, javascript, react, git, html, jquery, mongodb, java, Go, python, machine-learning, power-point) linkedin excel test lösungen, linkedin machine learning test
Stars: ✭ 7,014 (+3424.62%)
Mutual labels:  hacktoberfest
Fondo
📷 Wallpaper App for Linux
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Pajbot
Twitch moderation bot
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Lemuroid
All in 1 emulator on Android!
Stars: ✭ 194 (-2.51%)
Mutual labels:  hacktoberfest
React Native Pdfview
📚 PDF viewer for React Native
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Clipboard
React Native Clipboard API for both iOS and Android.
Stars: ✭ 198 (-0.5%)
Mutual labels:  hacktoberfest
Learn Python
List of resources useful for learning Python 🐍
Stars: ✭ 199 (+0%)
Mutual labels:  hacktoberfest
Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+1190.95%)
Mutual labels:  hacktoberfest

@react-native-segmented-control/segmented-control

Supports iOS and Android and WebGithub Action Badge npm Lean Core Extracted

React Native SegmentedControl library. Use SegmentedControl to render a UISegmentedControl iOS.

For Android and Web, it has a js implementation that mocks iOS 13 style of UISegmentedControl.

For Expo Users: Expo SDK 38 or later is required for this package.

iOS Android Web

Supported React Native Version

react-native-segmented-control react-native
v2.2.0 >= 0.62
<= v2.2.0 >= 0.57

This module is NOT supported for expo.

Getting started

Install the library using either Yarn:

yarn add @react-native-segmented-control/segmented-control

or npm:

npm install --save @react-native-segmented-control/segmented-control

Link

React Native 0.60+

The package is automatically linked when building the app. All you need to do is:

npx pod-install

For android, no linking is needed, as the module is implemented in js.

For React Native version 0.59 or older ### React Native <= 0.59

run react-native link @react-native-segmented-control/segmented-control

or you can follow the instructions to manually link this package.

Upgrading to React Native 0.60+

New React Native comes with autolinking feature, which automatically links Native Modules in your project. In order to get it to work, make sure you unlink Segmented Control first:

react-native unlink @react-native-segmented-control/segmented-control

Migrating from the core react-native module

This module was created when the segmentedControlIos was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:

import {SegmentedControlIOS} from 'react-native';

to:

import SegmentedControl from '@react-native-segmented-control/segmented-control';

Usage

Start by importing the library:

Use SegmentedControl to render a UISegmentedControl iOS.

Programmatically changing selected index

The selected index can be changed on the fly by assigning the selectedIndex prop to a state variable, then changing that variable. Note that the state variable would need to be updated as the user selects a value and changes the index, as shown in the example below.

import SegmentedControl from '@react-native-segmented-control/segmented-control';

return (
  <SegmentedControl
    values={['One', 'Two']}
    selectedIndex={this.state.selectedIndex}
    onChange={(event) => {
      this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
    }}
  />
);

Reference

Props

Inherits View Props.

enabled

If false the user won't be able to interact with the control. Default value is true.

Type Required
bool No

momentary

If true, then selecting a segment won't persist visually. The onValueChange callback will still work as expected.

Type Required Platform
bool No iOS

onChange

Callback that is called when the user taps a segment; passes the event as an argument

Type Required
function No

onValueChange

Callback that is called when the user taps a segment; passes the segment's value as an argument

Type Required
function No

selectedIndex

The index in props.values of the segment to be (pre)selected.

Type Required
number No

tintColor

Accent color of the control.

Type Required
string No

backgroundColor

Background color color of the control. (iOS 13+ only)

Type Required Supported Version
string No iOS 13+

values

The labels for the control's segment buttons, in order.

Type Required
(string number

appearance

(iOS 13+ only) Overrides the control's appearance irrespective of the OS theme

Type Required Platform
'dark', 'light' No iOS, Android, Web

fontStyle

(iOS 13+ only) | Type | Required | Platform | | ------ | -------- | -------- | | object | No | iOS, Android, Web |

An object container

  • color: color of segment text
  • fontSize: font-size of segment text
  • fontFamily: font-family of segment text
  • fontWeight: font-weight of segment text

activeFontStyle

(iOS 13+ only) | Type | Required | Platform | | ------ | -------- | -------- | | object | No | iOS, Android, Web |

  • color: overrides color of selected segment text
  • fontSize: overrides font-size of selected segment text
  • fontFamily: overrides font-family of selected segment text
  • fontWeight: overrides font-weight of selected segment text

Maintainers

Contributing

Please see the contributing guide.

License

The library is released under the MIT licence. For more information see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].