<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBrowserDelegate/browser(_:sizeToFitWidthOfColumn:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSBrowserDelegate(im)browser:sizeToFitWidthOfColumn:"
  },
  "title" : "browser(_:sizeToFitWidthOfColumn:)"
}
-->

# browser(_:sizeToFitWidthOfColumn:)

Returns the ideal width for a column.

```
@MainActor optional func browser(_ browser: NSBrowser, sizeToFitWidthOfColumn columnIndex: Int) -> CGFloat
```

## Parameters

`browser`

The browser.

`columnIndex`

The index of the column to size. If `-1`, the result is used to resize all columns.

## Return Value

The ideal width of the column. This method is used when performing a “right-size” operation, that is, when sizing a column to the smallest width that contains all the content without clipping or truncating.

## Discussion

If `columnIndex` is `–1`, you should return a size that can be uniformly applied to all columns (that is, every column will be set to this size).

Returning a value of `-1` allows you to opt-out of providing a width for the requested column.

## Discussion

This method applies only to browsers with resize type [`NSBrowser.ColumnResizingType.userColumnResizing`](/documentation/AppKit/NSBrowser/ColumnResizingType-swift.enum/userColumnResizing).

It is assumed that the implementation may be expensive, so it will be called only when necessary.

---

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)