React NativeScript

React NativeScript

  • Docs

›ELEMENTS: COMPONENTS

INTRODUCTION

  • Introduction

GETTING STARTED

  • Quick Start
  • Environment Setup
  • Using React Devtools

CORE CONCEPTS

  • Native Access
  • Navigation
  • Node Roles
  • Modals
  • Plugins
  • Styling

SAMPLES

  • Apps

ELEMENTS: LAYOUT

  • AbsoluteLayout
  • DockLayout
  • FlexboxLayout
  • GridLayout
  • StackLayout
  • WrapLayout

ELEMENTS: COMPONENTS

  • ActivityIndicator
  • ActionBar
  • ActionItem
  • Button
  • DatePicker
  • Frame
  • HtmlView
  • Image
  • Label
  • ListView
  • ListPicker
  • NavigationButton
  • Page
  • Placeholder
  • Progress
  • ScrollView
  • SearchBar
  • SegmentedBar
  • Slider
  • Switch
  • TabView
  • TabViewItem
  • TextField
  • TextView
  • TimePicker
  • WebView

LICENCES

  • Licences
Edit

SegmentedBar

<segmentedBar> is a UI bar component that displays a set of buttons for discrete selection. Can show text or images.

As opposed to <tabView>:

  • The position of <segmentedBar> is not fixed.
  • You can place and style it as needed on the page or inside additional app elements such as hamburger menus.
  • You need to handle the content shown after selection separately.

See also:

  • Official top-level documentation
  • Detailed API specification

import * as React from "react";

<segmentedBar>
  <segmentedBarItem title="First" />
  <segmentedBarItem title="Second" />
  <segmentedBarItem title="Third" />
</SegmentedBar>
<segmentedBar
  items={listOfItems}
  selectedIndex={0}
  selectedIndexChange={onSelectedIndexChange}
/>

Props

NameTypeDescription
itemsArray<SegmentedBarItem>An array of items to be displayed in the segmented bar. Represents the button labels or icons of the segmented bar.
The array must be created in advance.
selectedIndexnumberSets the index of the selected item.
selectedBackgroundColorColor(Style property) Sets the background color of the selected item. To set the background color of the entire bar, use backgroundColor.
onSelectedIndexChange(args:SelectedIndexChangedEventData) => voidEmitted when the an item on the segmented bar is tapped.

Native component

AndroidiOS
android.widget.TabHostUISegmentedControl
Last updated by Jamie Birch
← SearchBarSlider →
  • Props
  • Native component
React NativeScript
Docs
Getting StartedUI Components Reference
Community
Stack OverflowChat on Slack in #reactTwitter
More
GitHub – React NativeScriptGitHub – Docs Site
Copyright © 2021 Jamie Birch