-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedPR contribution is appreciatedPR contribution is appreciated
Description
Description
SwiftUI provides the tag(_:) modifier to set unique tag values on views. This is essential for differentiating among selectable views in containers like Picker and TabView. This API is currently missing from OpenSwiftUI.
API Reference
SwiftUI's tag modifier: https://developer.apple.com/documentation/swiftui/view/tag(_:)
Expected API
extension View {
func tag<V>(_ tag: V) -> some View where V: Hashable
}Use Case
The tag modifier is essential for:
- Picker - Identifying selectable options
- TabView - Differentiating between tabs
- NavigationLink - Selection-based navigation
- Any container that needs to identify and select among child views
Example Usage
struct FlavorPicker: View {
enum Flavor: String, CaseIterable, Identifiable {
case chocolate, vanilla, strawberry
var id: Self { self }
}
@State private var selectedFlavor: Flavor = .chocolate
var body: some View {
Picker("Flavor", selection: $selectedFlavor) {
ForEach(Flavor.allCases) { flavor in
Text(flavor.rawValue)
.tag(flavor)
}
}
}
}Priority
High - Blocking functionality for Picker, TabView, and other selection-based containers
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedPR contribution is appreciatedPR contribution is appreciated