协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
SearchBar【开发与工程】Expert guidance on SearchBar, a customizable SwiftUI search component. Use when developers mention: (1) SearchBar, (2) custom search bars in SwiftUI, (3) search tokens or suggestions, (4) styling search bars (glass, capsule), (5) cross-platform search (iOS, macOS, visionOS), (6) specific SearchBar modifiers like .searchBarStyle or .searchBarSuggestio…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
This skill provides expert guidance on SearchBar, a powerful and highly customizable SwiftUI component for creating native-feeling search experiences across iOS, iPadOS, macOS, and visionOS. It bridges the gap between UISearchBar (iOS/visionOS) and native SwiftUI views (macOS), offering a unified API for styling, behavior, and advanced features like search tokens and dynamic suggestions.
UISearchBar) vs. macOS (custom SwiftUI). Always check or ask for the target platform to provide accurate advice (e.g., specific material effects or token behaviors).SearchBar modifiers (e.g., .searchBarStyle, .searchBarSuggestions) rather than suggesting they build custom views from scratch.SearchBar is fully localized and adapts to system languages automatically.@State for text and tokens.#if os(...) directives if necessary (though the library handles most internally).Setting up a basic search bar?
references/SearchBar.mdCustomizing appearance?
references/SearchBarStyle.mdreferences/SearchBarStyle.mdreferences/SearchBarStyle.mdreferences/SearchBarModifiers.md (.searchBarIconView)Configuring behavior?
references/SearchBarDisplayModes.mdreferences/SearchBarModifiers.mdreferences/SearchBarModifiers.md (.searchBarIsFocused)Using advanced search features (iOS 16+/visionOS)?
references/SearchBarData.mdreferences/SearchBarData.mdreferences/SearchBarData.mdUISearchBar. Styling is consistent but underlying implementation differs..searchBarStyle(..., backgroundColor: .red). See references/SearchBarStyle.md..searchBarCancelButtonDisplayMode(.never). See references/SearchBarDisplayModes.md..searchBarMaterial(.glass). Note platform/version restrictions (iOS 26+). See references/SearchBarStyle.md.SearchBar(text: $text, prompt: "Search...")
.searchBarStyle(.rounded)
SearchBar(text: $text)
.searchBarStyle(.capsule, textColor: .white, tint: .blue, backgroundColor: .black.opacity(0.8))
.searchBarMaterial(.glass) // iOS 26+ (Experimental/Future)
SearchBar(text: $text)
.searchBarCurrentTokens($tokens)
.searchBarSuggestions($suggestions)
.searchBarEnableAutomaticSuggestionsFiltering(true)
SearchBar(text: $text)
.searchBarBeginEditingAction { print("Started") }
.searchBarEndEditingAction { print("Ended") }
.searchBarCancelButtonAction { print("Cancelled") }
SearchBar is integrated via Swift Package Manager.
https://github.com/SzpakKamil/SearchBar.git.import SearchBar in your Swift files.For detailed setup, see references/SearchBar.md.
SearchBar.md - General overview, setup, and initialization.SearchBarModifiers.md - Comprehensive list of all modifiers.SearchBarStyle.md - Styling, materials, corner styles, and scale.SearchBarDisplayModes.md - Cancel and Clear button behaviors.SearchBarData.md - Search Tokens and Suggestions._index.md - Index of all topics.