This is a SwiftUI color picker component library for macOS, designed to replace the default ColorPicker component. In addition, I’ve created another component library, ColorSelector, which offers a different user experience and a distinct style. The inspiration for this component comes from react-colorful, which I developed for a community member free of charge.
✦ My macOS/iOS application ✦
Welcome to download DevTutor, a cheat sheet app designed to help developers quickly build excellent applications using SwiftUI.
import Colorful
struct ContentView: View {
@State var color: Color? = Color.blue
@State var colorClear: Color? = .clear
var body: some View {
Colorful("Color", selection: $color, arrowEdge: .bottom)
.frame(width: 210)
Colorful(selection: $colorClear, arrowEdge: .top)
}
}
Use the showsAlpha
modifier to control the visibility of the alpha (opacity) slider in the picker panel.
import Colorful
struct ContentView: View {
@State var color: Color? = .clear
var body: some View {
ColorfulPicker(selection: $color)
.showsAlpha(false)
}
}
Licensed under the MIT License.