Skip to main content

SegmentedControl

The SegmentedControl component in our library is a user interface element used to enable users to make selections from a predefined set of options. It typically appears as a horizontal row of segmented buttons, each representing a distinct choice. Users can toggle between segments to indicate their selection preference, with only one segment active at a time. SegmentedControls are commonly used in applications to provide users with a clear and intuitive way to switch between different views, filters, or categories.

Usage

Basic usage

import {SegmentedControl} from 'rn-inkpad';

const App = () => {
const [value, setValue] = useState('tab1');

const values = [
{key: 'Tab 1', value: 'tab1'},
{key: 'Tab 2', value: 'tab2'},
];

return (
<SegmentedControl
label="Segmented Control"
values={values}
onChange={value => setValue(value)}
/>
);
};

Props

PropDescriptionTypeRequiredDefault
valuesKey and value array to generate each tab.{key: string; value: string}[]YesNone
onChangeFunction that returns the selected value.(value: string) => voidYesNone_
labelThe label with which you want to identify the segmentedControl.stringNoNone
labelStyleStyles for label.StyleProp<TextStyle>NoNone
selectedIndexSelected initial value.numberNo0
backgroundColorSegmentedControl background color.stringNo'#CCCCCC'
tintColorTint color for the selected tab.stringNo'#FFFFFF'
textColorText color in the segmentedControl.stringNo'#000000'
selectedTextColorText color en the selected tab.stringNo'#000000'
styleStyles for the component container.StyleProp<ViewStyle>NoNone

Example