Native <Host> components don't pass colorScheme, so Liquid Glass doesn't track theme changes
#208
Replies: 1 comment
|
You are right, and the diagnosis is exact — thank you for tracing it to the Two corrections to the scope, both in the direction of "worse than reported": There were six And a seventh of the same kind. On the implementation. Rather than reading the theme at each call site, the mode is passed by a small internal The source is A contract test now refuses a One thing I want to be straight about: this is iOS 26 Liquid Glass behaviour and I have not put eyes on it. It typechecks, builds and passes the suite, and the reasoning is from While in there, a second defect in the same file turned out to have the same root: |
Uh oh!
There was an error while loading. Please reload this page.
Summary
On iOS, native (
Host-backed) components render their Liquid Glass material using whatever color scheme@expo/ui'sHostresolves on its own, instead of the app's actual current theme. This causes a visible mismatch/flicker in dark mode: the native glass material stays light (or toggles inconsistently) while the rest of the screen (styled via CSS tokens) is correctly dark.Root cause
@expo/ui'sHostexposes acolorScheme?: 'light' | 'dark'prop specifically for this (@expo/ui/build/swift-ui/Host/index.d.ts), but none of PanelUI's native components pass it:src/components/button/index.tsx:406→<Host matchContents ignoreSafeArea="keyboard">src/components/bottom-sheet/index.tsx:703→<Host matchContents ignoreSafeArea="keyboard" style={{ position: 'absolute' }}>src/components/switch/index.tsxsrc/components/slider/index.tsxsrc/components/select/index.tsxWithout an explicit
colorScheme, the hosted SwiftUI content doesn't reliably track live theme changes — it appears to resolve once rather than following the app's actual (Uniwind-driven) theme state, so it can end up out of sync with the rest of the UI.Repro steps
glassin a navigation header, or navigate between screens that each render one.Confirmed
UIUserInterfaceStyleis correctly set toAutomatic.0.84.0(no mention in the changelog).Suggested fix
Pass
colorScheme={<resolved app theme>}(light/dark) on each of the 5<Host>calls above, sourced from the same theme state the rest of the library already reads (useTheme/useThemeMode).Affected components
Button(native + glass)Version
panelui-native@0.83.0(also checked0.84.0)Environment
expo: 57.0.17react-native: 0.86.3react: 19.2.3@expo/ui: 57.0.14expo-glass-effect: 57.0.1uniwind: 1.11.0All reactions