SegmentedButton
Button group component to select one or multiple options. Each unit Button just extends the Button component. Supports icons, multi-select, custom modes, sizes, statuses, and full styling customization.
Following values will be used on the following demos:
const buttons: ControlButtonProps[] = [
{ title: "Primary" },
{ title: "Secondary" },
{ title: "Tertiary" },
];
const iconButtons: ControlButtonProps[] = [
{ title: "Primary", left: <Icon name="add" /> },
{ title: "Secondary", left: <Icon name="add" /> },
{ title: "Tertiary", left: <Icon name="add" /> },
];
Usage
Primary
Secondary
Tertiary
function SegmentedButtonUsage() {
return <SegmentedButton data={buttons} />
}
Icons
Use the left or right prop in the data to display icons along with text in each segment.
Primary
Secondary
Tertiary
function SegmentedButtonIcons() {
return (
<View>
<SegmentedButton data={iconButtons} />
</View>
)
}
MultiSelect
Enable multiSelect prop to allow selecting multiple segments at once.
Primary
Secondary
Tertiary
function SegmentedButtonMultiSelect() {
return <SegmentedButton data={buttons} multiSelect />
}
Status
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
function SegmentedButtonStatuses() {
return (
<>
<SegmentedButton data={buttons} mode="filled" status="primary" />
<SegmentedButton data={buttons} mode="filled" status="accent" />
<SegmentedButton data={buttons} mode="filled" status="success" />
<SegmentedButton data={buttons} mode="filled" status="info" />
<SegmentedButton data={buttons} mode="filled" status="warning" />
<SegmentedButton data={buttons} mode="filled" status="error" />
</>
)
}
Size
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
function SegmentedButtonSizes() {
return (
<View>
<SegmentedButton data={buttons} size="small" />
<SegmentedButton data={buttons} size="medium" />
<SegmentedButton data={buttons} size="large" />
</View>
)
}
Modes
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
Primary
Secondary
Tertiary
function SegmentedButtonModes() {
return (
<View>
<SegmentedButton data={buttons} mode="filled" />
<SegmentedButton data={buttons} mode="tinted" />
<SegmentedButton data={buttons} mode="outlined" />
<SegmentedButton data={buttons} mode="plain" />
</View>
)
}
Disabled
Use the disabled prop to make segments non-interactive.
Primary
Secondary
Tertiary
function SegmentedButtonDisabled() {
return <SegmentedButton data={buttons} disabled />
}
Custom
Primary
Secondary
Tertiary
function SegmentedButtonCustom() {
return (
<View>
<SegmentedButton
data={buttons}
style={[{backgroundColor: 'cyan'}]}
activeColor="cyan"
inactiveColor="burlywood"
/>
</View>
)
}
Props
| Prop | Data Type | Default Value | Description |
|---|---|---|---|
| Extends | BaseUIProps | -- | Inherits properties from BaseUIProps |
| data | ControlButtonProps[] | -- | List of props for control buttons |
| mode | ButtonMode | -- | Mode of the button view |
| fullWidth | boolean | -- | Take the full width available |
| borderRadius | number | -- | Control the border radius of the edge buttons |
| withVerticalDivider | boolean | -- | Show the vertical divider between the buttons |
| multiSelect | boolean | -- | Set to true for multiple select |
| activeColor | string | -- | active color when the button is selected |
| inactiveColor | string | -- | inactive color when the button is unselected |
| style | StyleProp<ViewStyle> | -- | Container style |
| disabled | boolean | -- | Disable the whole control |
| onPress | (value: string, selectedIndex: number) => void | -- | OnPress callback with value |
| status | BlossomStatus | primary | -- |
| size | BlossomSize | medium | -- |