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

    colors

    The color token configuration.

    typography

    The typography scale.

    spacing

    The spacing scale.

    radii

    The corner radius scale.

    shadows

    The shadow styles for various elevations.

    stroke

    The stroke styles.

    shapes

    The shapes styles used for various components.

    buttons

    The buttons default values used when no modifier applied

  • The default theme configuration optimized for light mode. Uses defaultLight for 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 defaultDark for colors and shadows, and shared defaults for other scales.

    Declaration

    Swift

    public static var defaultDark: Theme
  • Returns a new Theme instance 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
    ) -> Theme

    Parameters

    colors

    The color token configuration.

    typography

    The typography scale.

    spacing

    The spacing scale.

    radii

    The corner radius scale.

    shadows

    The shadow styles for various elevations.

    stroke

    The stroke styles.

    shapes

    The shapes styles used for various components.

    buttons

    The buttons default values used when no modifier applied

    textFields

    The text field default values used when no modifier applied