View styles
Apply built-in and custom appearances and behaviors to different types of views.
Overview
SwiftUI defines built-in styles for certain kinds of views and automatically selects the appropriate style for a particular presentation context. For example, a Label might appear as an icon, a string title, or both, depending on factors like the platform, whether the view appears in a toolbar, and so on.
[Image]
You can override the automatic style by using one of the style view modifiers. These modifiers typically propagate throughout a container view, so that you can wrap a view hierarchy in a style modifier to affect all the views of the given type within the hierarchy.
Any of the style protocols that define a makeBody(configuration:) method, like ToggleStyle, also enable you to define custom styles. Create a type that conforms to the corresponding style protocol and implement its makeBody(configuration:) method. Then apply the new style using a style view modifier exactly like a built-in style.
Topics
Styling views with Liquid Glass
Applying Liquid Glass to custom viewsLandmarks: Building an app with Liquid GlassglassEffect(_:in:)interactive(_:)GlassEffectContainerGlassEffectTransitionGlassButtonStyleGlassProminentButtonStyleDefaultGlassEffectShape
Styling buttons
buttonStyle(_:)ButtonStyleButtonStyleConfigurationPrimitiveButtonStylePrimitiveButtonStyleConfigurationsignInWithAppleButtonStyle(_:)
Styling pickers
Styling menus
Styling toggles
Styling indicators
gaugeStyle(_:)GaugeStyleGaugeStyleConfigurationprogressViewStyle(_:)ProgressViewStyleProgressViewStyleConfiguration
Styling views that display text
labelStyle(_:)LabelStyleLabelStyleConfigurationtextFieldStyle(_:)TextFieldStyletextEditorStyle(_:)TextEditorStyleTextEditorStyleConfiguration
Styling collection views
listStyle(_:)ListStyletableStyle(_:)TableStyleTableStyleConfigurationdisclosureGroupStyle(_:)DisclosureGroupStyle
Styling navigation views
Styling groups
controlGroupStyle(_:)ControlGroupStyleControlGroupStyleConfigurationformStyle(_:)FormStyleFormStyleConfigurationgroupBoxStyle(_:)GroupBoxStyleGroupBoxStyleConfigurationindexViewStyle(_:)IndexViewStylelabeledContentStyle(_:)LabeledContentStyleLabeledContentStyleConfiguration