Overview
MarkdownTheme.Colors defines the color scheme used for rendering markdown content. It provides customization for text colors, highlights, code blocks, and interactive elements.
Declaration
Properties
Text Colors
The color used for body text.Default (iOS/visionOS):
UIColor.label (adapts to light/dark mode)Default (macOS): NSColor.labelColor (adapts to light/dark mode)The color used for emphasized text (italic, strong emphasis).Default: Accent color from asset catalog, falls back to system orange.Lookup order:
AccentColor → accentColor → .systemOrangeLink and Highlight Colors
The color used for links and highlighted elements.Default: Accent color from asset catalog, falls back to system orange.Lookup order:
AccentColor → accentColor → .systemOrangeCode Colors
The text color used for code blocks and inline code.Default (iOS/visionOS):
UIColor.labelDefault (macOS): NSColor.labelColorThe background color for code blocks and inline code.Default:
UIColor.gray.withAlphaComponent(0.25) / NSColor.gray.withAlphaComponent(0.25)Provides a subtle gray background to distinguish code from regular text.Selection Colors
The background color for selected text. Optional.Default: Accent color with 20% opacity.Lookup order:
AccentColor → accentColor → .systemOrange, then applies .withAlphaComponent(0.2)Set to nil to use the system default selection color.Platform Types
- iOS/visionOS: Uses
UIColorfrom UIKit - macOS: Uses
NSColorfrom AppKit
Example
Dark Mode Support
All default colors use semantic system colors that automatically adapt to light and dark mode:UIColor.label/NSColor.labelColor- Primary text colorUIColor.gray/NSColor.gray- Neutral grayUIColor.systemOrange- Accent fallback color
Accent Color Resolution
Thehighlight and emphasis properties attempt to use your app’s accent color:
- First checks for
AccentColorin the asset catalog - Falls back to
accentColor(lowercase) - Finally falls back to
.systemOrange
AccentColor to your asset catalog.