How to create a NSToolbarItem with a custom view

How can you create a custom NSToolbarItem that appears like say the Safari address bar?

More specifically, one that has the background color, shadow and rounded corners.

Additionally, it responds to the inactive stage of the window


as well as supporting Dark Mode in macOS Mojave.


Is it done via the use of an NSBox? Is it using a custom NSButton?

Just to clarify. I am familiar with the intricacies of Dark Mode, how to make rounded corners, create a NSToolbarItem with a custom view etc.


I am looking for a canonical answer as to how to create a custom NSToolbarItem that adheres to the principles of the ones provided by AppKit.