Skip to content

apportionsSegmentWidthsByContent #883

Open

Description

@DenisDov

Is there any possibility to use apportionsSegmentWidthsByContent from UISegmentedControl to adjust segment widths based on their content widths?

Activity

  1. iankberry commented on Dec 20, 2024

    @iankberry

    +1 To this. It would especially be useful when there is limited horizontal space and some labels are shorter than others.

    SCR-20241220-irm

  2. enchorb commented on Aug 14, 2025

    @enchorb

    +1, for now we added with the patch below

    diff --git a/index.d.ts b/index.d.ts
    index aa8d5f54d135e16952d630084571e872329dc26b..4b4bf423288413dbbc17b0db33deabf7e2c79179 100644
    --- a/index.d.ts
    +++ b/index.d.ts
    @@ -116,6 +116,8 @@ export interface SegmentedControlProps extends ViewProps {
        * Style properties for the Animated.View component
        */
       sliderStyle?: ViewStyle;
    +
    +  apportionsSegmentWidthsByContent?: boolean;
     }
    
     /**
    diff --git a/ios/RNCSegmentedControlManager.m b/ios/RNCSegmentedControlManager.m
    index 553bc1f35d40fa196fb70dfff3e3a82924262cc6..70081e2c01a87a72cc6eea177fd0531106baded0 100644
    --- a/ios/RNCSegmentedControlManager.m
    +++ b/ios/RNCSegmentedControlManager.m
    @@ -25,6 +25,7 @@ RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
     RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
     RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL)
     RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
    +RCT_EXPORT_VIEW_PROPERTY(apportionsSegmentWidthsByContent, BOOL)
     RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
     RCT_EXPORT_VIEW_PROPERTY(appearance, NSString)
     RCT_EXPORT_VIEW_PROPERTY(testIDS, NSArray)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions