How to decide show which component based on dark mode statu? #4238
-
QuestionHi everyone. I try to show diffrent images in diffrent darkmode.I try to use None means use system setting.When system use dark,Nicegui will use dark,too. Is there any way to slove this problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @weinibuliu, There's discussion #2415 about how to get the user preference when dark mode is set to |
Beta Was this translation helpful? Give feedback.
Here is how you can show and hide elements based on the current mode:
The class "dark:!block" will display the element as a normal "block" only in dark mode. Otherwise the element is hidden. The exclamation mark
!
is needed to overrule the "hidden" class.Alternatively you can create your own classes with some custom CSS, which might be more handy: