Skip to content

Instantly share code, notes, and snippets.

@electricsidecar-dev
Last active May 27, 2025 18:28
Show Gist options
  • Save electricsidecar-dev/ec618885c08558948584e9ad35b60eff to your computer and use it in GitHub Desktop.
Save electricsidecar-dev/ec618885c08558948584e9ad35b60eff to your computer and use it in GitHub Desktop.
Duolingo button
import SwiftUI
struct DuolingoButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.textCase(.uppercase)
.fontWeight(.bold)
.fontDesign(.rounded)
.frame(maxWidth: .infinity)
.padding()
.background(Color(#colorLiteral(red: 0.3298856616, green: 0.7584818006, blue: 0.008744089864, alpha: 1)))
.clipShape(.rect(cornerRadius: 12))
.foregroundStyle(.white)
.shadow(color: Color(#colorLiteral(red: 0.3453077376, green: 0.6464449763, blue: 0, alpha: 1)), radius: 0, y: configuration.isPressed ? 0 : 4)
.offset(y: configuration.isPressed ? 4 : 0)
.animation(.bouncy(duration: 0.2), value: configuration.isPressed)
.sensoryFeedback(
configuration.isPressed
? .impact(flexibility: .soft, intensity: 0.75)
: .impact(flexibility: .solid),
trigger: configuration.isPressed
)
}
}
struct DuolingoButton: View {
var body: some View {
VStack {
Button {} label: {
Text("Check")
}
.buttonStyle(DuolingoButtonStyle())
}
.padding()
}
}
#Preview {
DuolingoButton()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment