A modular way for widget styling and themes #4509
-
Looking for a modular way for styling widgets and themesHello. I am currently trying to figure out a good way to have modular Textual CSS for my Textual application. The current project structure would look something like this:
The current problemsSeparating the CSS from the source filesOne "problem" is that I currently inlining all my CSS in the widgets and the app via the Ideally, I would like to have something like in most web applications where the structure would be something like:
And then inside I have read the documentation and have looked at some textual projects, but people usually tend to inline the CSS with the Additionally, there is no way to refer to the root path of the project like Is it possible to have a structure like this ? Sharing CSS variablesI am also struggling to set up my themes for the application. For now, I want a dark mode and light mode theme. To do so, I would like to define my own CSS variables, perhaps: /* Inside root.tcss file ? */
$my-primary-light: #ebdbb2;
$my-primary-dark: #282828; And then in my other CSS files, I can refer to those variables as: /* Inside screens/screen1.tcss */
.screen1 { /* selector for some element on the screen */
color: $my-primary-dark;
&:light {
color: $my-primary-light;
}
} My idea for this want to create a How could I implement a theme variable structure like this ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
CSS_PATH
is only available for theApp
andScreen
classes, so I'm afraid the short answer is no. I think there's a feature request knocking around in the issues to also add this toWidget
, but I'm not sure if there are plans to implement this.