Chip Component
The Chip Component is a reusable view that allows you to create customizable chips with different states, such as enabled, selected, and disabled. Chips are versatile UI elements commonly used for displaying tags, options, or filters.
Features
- Create choice chips, filter chips, action chips, and input chips.
- Customize chip titles, states, icons, and appearance.
- Interact with chips through tap gestures or input fields.
- Supports accessibility features for improved user experience.
Installation
-
Copy the
OCChip
component folder into your Xcode project. -
Use the
OCChip
view in your SwiftUI code:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
OCChip(title: "Enabled Chip", state: .enabled, type: .choice) { state in
print("Chip selected state: \(state)")
}
OCChip(title: "Input Chip", state: .enabled, type: .input(leftIcon: Image(systemName: "circle"), inputText: "Label")) { state in
print("Chip selected state: \(state)")
}
}
}
}