I'm trying to create an NSToolbar with items similar to the Apple's Mail app on macOS. I have an issue with the default toolbar item's width though, as it seems to be inconsistent. Since Big Sur, the items are meant to be sized automatically by AppKit and the NSToolbarItem minSize, maxSize properties have been deprecated.
I'm setting the image property for each NSToolbarItem, not using custom views. As you can see in the screenshots below, the envelope icon has a different "highlight" area (less padding on the sides) while the trash icon has a much larger highlight area.
The envelope icon is a single NSToolbarItem while the archive box and trash items are displayed using NSToolbarItemGroup with NSSegmentedControl view.
In the Apple's Mail app, even single toolbar items have the same width as the grouped items:
How to increase the toolbar item's width when using an image instead of custom view?



Deprecating a property and leaving you in the dark how to achieve a until recently simple effect without using the deprecated property is typical for how Apple deals with AppKit nowadays.
I would not be surprised of the Mail app still uses the deprecated
minSizeproperty, or that theNSToolbarItemobjects are based onNSButtonviews with a minimum widthNSLayoutConstraint(which is my current solution).To continue using
minSizewithout deprecation warnings, you can consider to use a simpleToolbarItemclass like this: