Theme & Layout
Get the app theme
Returns the app's colors and font families, already resolved for the current light or dark mode.
bridge.getTheme() // → Promise<Theme>Parameters: none.
Resolves with colors matched to the current Blynk theme — no prefers-color-scheme adaptation needed — plus the font families the app uses.
brand
blynkBrandColor6
Primary accent, buttons, focus rings
primary
blynkPrimaryColor6
Secondary accent
positive
blynkPositiveColor6
Success, online status
warning
blynkWarningColor6
Warning badges
critical
blynkCriticalColor6
Errors, offline status
background
blynkBackgroundColor
Page and widget background
textPrimary
blynkTextPrimaryColor
Body text
onPrimary
blynkOnPrimaryColor
Text on primary-colored surfaces
onBrand
blynkOnBrandColor
Text on brand-colored surfaces
neutral
blynkNeutralColor9
Muted text, borders
Colors are CSS color strings and may carry an alpha channel (#rrggbbaa), so derive tints with color-mix() rather than by appending hex digits.
primaryFont
Body text and general labels
secondaryFont
Sub-labels, captions, helper text
buttonsFont
Buttons and interactive elements
widgetValuesFont
Numeric and data-value display
Font fields are string | null — present only when the app has custom typography. Use them as CSS font-family values with a system-font fallback. The host injects the matching @font-face rules for you.
Rejects with request_timeout (web, 10 seconds — Theme request timeout (10s)), device_unavailable, bridge_destroyed.
Reacting to theme changes — register onThemeUpdated and apply the theme both at boot and in the callback. That covers every host:
Web:
onThemeUpdatedfires on a light/dark switch and on organization branding changes.Mobile: a light/dark switch either reloads the widget or is delivered through
onThemeUpdated, depending on the app. The callback also fires once when custom fonts finish loading after an earliergetTheme()returned them incomplete.
Example
Keep fallback values in
:rootso the widget looks right in the browser and editor beforegetTheme()resolves.
CSS custom properties
The prefers-color-scheme block is a fallback for the editor and browser only. Inside a Blynk host, getTheme() returns colors for the current Blynk theme — which can differ from the OS preference — so always call it and apply its values.
Responsive layout with container queries
The widget tile can be any size, so adapt with CSS container queries rather than viewport media queries:
Use clamp() with container units for fluid type: font-size: clamp(12px, 3cqmin, 15px);. Container query units (cqw, cqh, cqmin, cqmax) work in Blynk WebViews.
Was this helpful?

