Skip to content

Segmented Buttons not showing correctly when there is only 1 element in buttons prop #4593

@Jaydaawesomedood

Description

@Jaydaawesomedood

Context

I have a form with a couple of Segmented Buttons to create a standardized view for each field in the form. Currently, one of the fields I have only have one button at this point of time, as I will intend to add more options in the future.

Current behaviour

Currently, when there is only one element in the 'buttons' prop, the button does not "close" itself forming a loop.
Where "close" itself refers to the right end of the button is open, unlike the Segmented Buttons with more than 1 element in the buttons prop that will "close" itself.

Expected behaviour

The Segmented Button even with 1 element in the buttons prop should form a complete loop instead of leaving the right end open.

How to reproduce?

Insert 1 element only in the buttons prop when creating a SegmentedButton.
E.g.,

<SafeAreaView style={styles.container}>
      <SegmentedButtons
        value={value}
        onValueChange={setValue}
        buttons={[
          {
            value: 'walk',
            label: 'Walking',
          }
        ]}
      />
</SafeAreaView>

Preview

Image

Your Environment

software version
react-native 0.76.5
react-native-paper 5.12.5
expo sdk 52.0.23


I can use a single disabled button to replace this specific use case for now, but I would personally prefer having a more standardized view since the other controls are of Segmented Buttons.

My question now is, does Segmented Button support buttons prop with 1 single element as of now? If no, are there any plans in the future to include this use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions