0.3.3 • Published 12 months ago

react-navtive-segment-control v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

react-navtive-segment-control

Segment Control RN

Installation

npm install react-navtive-segment-control
yarn add react-navtive-segment-control

Usage

  • Import Component
import { SegmentControl } from'react-navtive-segment-control';
 <SegmentControl
    segments={data}
    activeTab={activeTab}
    onPress={(value) => {
      console.log(value);
    }}
  />
  • Example:
import react, {useState}from 'react'
import { RefObject, SegmentControl } from 'react-navtive-segment-control';

const data = [
  {label : "Left", icon : "left"},
  {label : "Right", icon : "right"}
  ]

const App = ()=>{
  const [activeTab,setActiveTab] = useState(0)
  return (
    <SegmentControl
      segments={data}
      activeTab={activeTab}
      onPress={(value) => {
        // value is object active in data
        console.log(value);
      }}
    />
  )
}
export default App

Reference

Props


segments

an array of objects segments

TypeRequired
arrayYes

activeTab

index of array in segment

TypeRequired
numberYes

labelField

key label you want to display (in the object of the segment array)

TypeRequireddefault
stringNotitle

iconField

key icon you want to display (in the object of the segment array)

TypeRequireddefault
stringNoicon

duration

duration animated

TypeRequireddefault
numberNo300ms

style

style container

TypeRequireddefault
objectNo

activeStyle

style box active

TypeRequireddefault
objectNo

textStyle

textStyle box

TypeRequireddefault
objectNo

textActiveStyle

textActiveStyle box active

TypeRequireddefault
objectNo

onPress

Press Segment

onPress((value,i)=>{})
TypeRequireddefault
functionNo

updateActive

updateActive of Ref segment

updateActive(index)
TypeRequireddefault
functionNo

License

MIT


Made with create-react-native-library

0.3.3

12 months ago

0.3.2

12 months ago

0.3.1

12 months ago

0.2.0

12 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago