I need to get the color scheme of the app to give some styles to a button content. I want to use it in a foregroundColor for example.
Asked
Active
Viewed 363 times
1 Answers
1
It turns out it's pretty easy. You just need to do this:
@Environment(\.colorScheme) var colorScheme
Button {} label: {
Text("Hello World")
}.foregroundColor(colorScheme == .dark ? .white : .black)

Samuel O.D.
- 346
- 2
- 13