<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSegmentedControl/width(forSegment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSegmentedControl(im)widthForSegment:"
  },
  "title" : "width(forSegment:)"
}
-->

# width(forSegment:)

Returns the width of the specified segment.

```
func width(forSegment segment: Int) -> CGFloat
```

## Parameters

`segment`

The index of the segment whose width you want to get. This method raises an exception (<doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException>) if the index is out of bounds.

## Return Value

The width of the segment, measured in points, or 0 if the segment is sized to fit the available space automatically.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)