Theme
public struct Theme
A complete representation of a visual theme including color, typography, spacing, radius, and shadow tokens.
The Theme struct is the root context for all styling logic in a themed SwiftUI application.
-
The set of color tokens used throughout the UI. Includes semantic roles like
primary,onSurface,background, etc.Declaration
Swift
public let colors: ThemeColors -
The full typography scale used for all text elements, including headings, body text, and labels.
Declaration
Swift
public let typography: ThemeTypography -
The standard spacing scale for padding, margins, and layout spacing.
Declaration
Swift
public let spacing: ThemeSpacing -
The radius scale used for rounded corners and clip shapes.
Declaration
Swift
public let radii: ThemeRadii -
The set of shadow styles representing elevation or focus states.
Declaration
Swift
public let shadows: ThemeShadows -
The set of stroke styles
Declaration
Swift
public let stroke: ThemeStroke -
The set of shapes styles used in clipShape modifiers
Declaration
Swift
public let shapes: ThemeShapes -
The set of buttons default configurations
Declaration
Swift
public let buttons: ThemeButtonDefaults -
The set of buttons default configurations
Declaration
Swift
public let textFields: ThemeTextFieldDefaults -
Initializes a new theme instance with custom tokens.
Declaration
Swift
public init( colors: ThemeColors, typography: ThemeTypography, spacing: ThemeSpacing, radii: ThemeRadii, shadows: ThemeShadows, stroke: ThemeStroke, shapes: ThemeShapes, buttons: ThemeButtonDefaults, textFields: ThemeTextFieldDefaults )Parameters
colorsThe color token configuration.
typographyThe typography scale.
spacingThe spacing scale.
radiiThe corner radius scale.
shadowsThe shadow styles for various elevations.
strokeThe stroke styles.
shapesThe shapes styles used for various components.
buttonsThe buttons default values used when no modifier applied
-
The default theme configuration optimized for light mode. Uses
defaultLightfor colors and shadows, and shared defaults for other scales.Declaration
Swift
public static var defaultLight: Theme -
The default theme configuration optimized for dark mode. Uses
defaultDarkfor colors and shadows, and shared defaults for other scales.Declaration
Swift
public static var defaultDark: Theme -
Returns a new
Themeinstance by copying the current one and applying the specified overrides.Declaration
Swift
func copy( colors: ThemeColors? = nil, typography: ThemeTypography? = nil, spacing: ThemeSpacing? = nil, radii: ThemeRadii? = nil, shadows: ThemeShadows? = nil, stroke: ThemeStroke? = nil, shapes: ThemeShapes? = nil, buttons: ThemeButtonDefaults? = nil, textFields: ThemeTextFieldDefaults? = nil ) -> ThemeParameters
colorsThe color token configuration.
typographyThe typography scale.
spacingThe spacing scale.
radiiThe corner radius scale.
shadowsThe shadow styles for various elevations.
strokeThe stroke styles.
shapesThe shapes styles used for various components.
buttonsThe buttons default values used when no modifier applied
textFieldsThe text field default values used when no modifier applied