Skip to content
GitHub

Settings chrome

The chrome (top bar, lock for keep-open, and Settings gear) is driven by flags on NookConfiguration.topBar. You can replace the leading identity (label and icon), change the bar’s glyphs, strip the top bar entirely, keep the bar while dropping the gear, or draw a bar of your own that keeps the framework’s behavior.

var configuration = NookConfiguration()
// Replace the leading identity. Defaults: title "Home", OpenNook brand mark.
configuration.topBar.leadingTitle = { _ in "Today" }
configuration.topBar.leadingIcon = "house" // SF Symbol override; nil keeps the brand mark
// Chrome flags.
configuration.topBar.showsTopBar = true // false strips top bar + gear + lock
configuration.topBar.showsSettings = true // false drops the gear (top bar stays)
configuration.topBar.notchClearance = .automatic // .manual lets content run up beside the notch
// Move the lock or the gear somewhere else, keeping the feature.
configuration.topBar.showsKeepOpenButton = true // false takes the lock out of the bar
configuration.topBar.showsSettingsButton = true // false takes the gear out of the bar
// The bar's glyphs, a custom leading icon, or a whole bar of your own.
configuration.topBar.symbols.settings = "slider.horizontal.3"
configuration.topBar.setLeadingIcon { color in Monogram(color: color) }
configuration.setTopBar { bar in MyTopBar(bar: bar) }

The glyphs, the leading icon view, and the replacement bar are covered in Top-bar glyphs and Replacing the top bar.

When false, the chrome shell renders only your home view inside the expanded surface. No top bar, no gear, no lock. Use this when your view owns the entire surface.

Settings and keep-open are still there without the bar. Put NookKeepOpenButton and NookSettingsButton in a companion surface or your home view (see below), call \.nookChromeActions from your own controls, or use the menu-bar item. showsSettings still decides whether Settings exists at all.

The content still starts below the notch, where the bar would have ended. To put icons beside the notch, or to let the content run up to the top, see Clearing the notch.

When false, the top bar remains (so the lock and any leading identity are still visible) but the gear is removed. Use this when you ship without exposing the framework’s Settings panels.

Each removes one glyph from the top bar without removing its feature. Keep-open stays in Settings and the menu bar, and Settings stays reachable from the menu bar and AppCoordinator.showSettings(). Use them to show the controls somewhere else - typically in a companion surface with the framework’s NookKeepOpenButton and NookSettingsButton, or in your own controls through the \.nookChromeActions environment value:

configuration.topBar.showsKeepOpenButton = false
configuration.topBar.showsSettingsButton = false
configuration.addCompanion(id: "chrome-controls", anchor: .trailing, hidesInSettings: false) {
ChromeControls() // a VStack of NookKeepOpenButton() and NookSettingsButton()
}

The built-in Settings screen shows five framework groups - Appearance, Display, Shortcut & nook, Data, and About - then any sections you add with addSettingsSection(title:content:). Leave a group out of settingsGroups to hide it and keep the rest:

configuration.settingsGroups = [.appearance, .shortcut, .about] // no Display or Data

Every string the built-in screen draws comes from NookConfiguration.labels (NookChromeLabels): the group titles in labels.settings, and the rows of each group in labels.appearance, labels.display, and labels.shortcut. The public sections read the same labels, so they follow them in a Settings screen of your own.

configuration.labels.settings.appearanceTitle = "Look"
configuration.labels.settings.shortcutTitle = "Keyboard"
configuration.labels.shortcut.stayExpandedTitle = "Keep open"
configuration.labels.shortcut.stayExpandedOn = "On - stays open after the pointer leaves"
configuration.labels.display.builtIn = "This Mac's display"

Renaming a group keeps it open or closed. See Labels for every group and for templates such as labels.shortcut.showHostFormat ("Show {host}").

setSettings(_:) replaces the built-in screen. The framework’s groups are public views, so your screen keeps the ones you want beside your own, drawn the same way with NookSettingsGroup:

struct MySettings: View {
@EnvironmentObject private var appState: AppState
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
NookSettingsGroup("Account") { AccountRows() }
NookSettingsGroup("Appearance") { NookAppearanceSettingsSection(appState: appState) }
NookSettingsGroup("Display", isInitiallyExpanded: false) {
NookDisplaySettingsSection(appState: appState)
}
NookSettingsGroup("Shortcut & nook", isInitiallyExpanded: false) {
NookShortcutSettingsSection(appState: appState)
}
NookSettingsGroup("Data", isInitiallyExpanded: false) { NookResetSettingsSection() }
NookSettingsGroup("About", isInitiallyExpanded: false) { NookAboutSettingsSection() }
}
}
}
}
configuration.setSettings { MySettings() }
View What it shows
NookAppearanceSettingsSection(appState:) Theme, surface, layout, accent, and strength
NookDisplaySettingsSection(appState:) Which display the nook is on
NookShortcutSettingsSection(appState:) The global shortcut, “Stay expanded”, haptic feedback, and “Sounds” while the theme has sounds
NookResetSettingsSection() “Reset All Settings”
NookAboutSettingsSection() The host’s name, version, and tagline

Each writes through AppState and the chrome’s actions, exactly as the built-in screen does, so they need to sit inside chrome content - the Settings screen, home, or a companion. NookSettingsGroup keeps its own open or closed state, or takes an isExpanded binding.

Reset returns appearance, the shortcut, and the display to your preferenceDefaults and forgets the person’s choices; see Launch defaults.

The leading cluster is the home glyph plus a label on the home surface. Both are functions of AppState, so they can follow your product state.

Defaults are "Home" for the title and the OpenNook brand mark for the icon (leadingIcon is nil). Set leadingIcon to an SF Symbol name, such as "house", to use your own glyph, or setLeadingIcon to draw any view there. Set leadingTitle to return an empty string if you want a title-only cluster with no icon override.

  • Companion surfaces - floating the lock and gear, or any host control, beside the nook.
  • Theming - replace the built-in Settings screen with setSettings(_:), the companion to showsSettings.
  • Your first nook - where the topBar flags first appear, alongside the other NookConfiguration knobs.