Tips for creating a theme (or overrides) for a desktop-like looking
I have been reading the documentation of quasar, and indeed the customization system it looks very powerful.
What I want is tips to customize the stylus variables to make the interface match a desktop app (or close to it):
- Toolbars with all buttons close to each other (no space)
- Buttons with a clear border, and some glossy effect
- Toolbars with the exact same size of the buttons it holds, plus a border
- Input fields with less space between them
This forum for example, is closer to what I want to achieve than the default MAT theme
This should all be achievable by either writing a theme from scratch, which gives you total freedom or by taking the Material Theme as a base and overwriting the styles. For styles that are not changeable via the variables, look at the source code of the components and take note of the class names, that overwrite these styles as you like.
It’s a bit hard to give specific advice because you asked for a lot of things and you are not very concrete with your requirements. If you have a specific problem on achieving the desired output, why you can describe in more detail I think people can help you better.
Thanks for your answer. Indeed I wanted to provide more detailed information (including some screenshots) but I wanted to get first some advice about which places to look into. For example, how can I write a theme from scratch? Can I just copy one of the existing ones and start modding it out of the box ? Will it be easier to start overwriting variables until I get stuck ? Reading document seems that I can only override variables once , in one specific file . Am I wrong ? Can I just create a file that overrides certain variables and include it ?
Honestly, I think writing a theme from scratch would be a bit too much if you just started with Quasar.
But nevertheless, here are some starting points for writing a new theme.
First, take a look at the Quasar Source. This is the place where the Material Theme is defined: https://github.com/quasarframework/quasar/blob/dev/src/css/mat.styl
Take not that it just import from various places, there is a normalization style, base style, variables and then each component gets imported.
The component styles all reside in `src/components/<component-name>. For example here is the Input Material Style. https://github.com/quasarframework/quasar/blob/dev/src/components/input/input.mat.styl
If you wanted to write your own Theme you could just write one large CSS file, but this will be hard to maintain. Also, you can not copy an existing theme as one file, because of the imports. Instead, you should create stylus files for every component and import them in a base file, like Quasar does it.
But I would start with just overwriting variables and if you get stuck try to overwrite parts of the Styles.
For overwriting variables please refer to the docs: http://beta.quasar-framework.org/guide/quasar-theming.html
@a47ae Thank you very much, this answer was exactly what I also was just looking for. I am relatively new to GUI frameworks like Quasar and am also investigating its uses for someone who wants to create a “desktop–first” look ;)
Great to hear that each component has its own Stylus file, this basically sold me. I’m fine with doing some reverse-engineering via the console, but my projects demands full control over every pixel, so this just got easier to imagine with Quasar.
Glad I could help, if you have any other questions feel free to ask :)
@a47ae Thanks for the nice offer! :) Actually I do have a related question.
I would like to globally override certain CSS variables of Quasar components that I will be using, so that I don’t have to worry about locally having to change their appearane again and again.
So I set up my first Qusar project using the Material Design theme, which I activated doing so in my main.js:
One thing that I don’t yet quite understand (due to my lack of the Quasar setup) is where to put my custom override variables. Do I put them in a newly created file “quasar.variables.styl” in /themes or do I include them in the “Quasar Material Design Stylus” section of app.mat.styl? Both ways don’t work for me.
Maybe you could elaborate on that, since it should be a simple newbie question? ;) Cheers!
So the variables you want to override for all themes belong in
The theme specific variables belong in
This is because some variables are only relevant for e.g. the Material Design Theme. You can find the variable names here: http://beta.quasar-framework.org/components/stylus-variables.html . Note that on some variables it tells you
Not Applicablewhich indicates that this varaible is only used in the other theme.
So for things like colors and stuff, I would out the overrides into
Try to enter the following in there:
$primary = #2DE363this should give you a green primary color and therefore for example a green top bar.
For component specific stuff I would put the overrides into
./themes/app.mat.styl. So for example to change the alert padding put
$alert-padding = 2remright before the line
If you want to override styles, I would create a new folder inside
./themesand create a stylus file for each component. Then create a file
<my-theme>.stlyin the same folder and import all the component styles in there. Finally in
And always make sure that you comment out he
)line and comment in the
main.jsto use custom themes.
@a47ae Wow thank you for that lightning-fast response! :thumbsup: Will give it a try.
Just one thing regarding your last sentence: In the main.js it says that
// 1. use next line to activate CUSTOM STYLE (./src/themes)
while you wrote to comment out the above and rather use
// 2. or, use next line to activate DEFAULT QUASAR STYLE
Did I understand this correctly? I undestood the inline comments in main.js the other way around.
Ups, this was more a language problem, English is not my first language :D
With “comment out” I actually meant the exact opposite thing (remove the comment), so your understanding of the inline comments is correct and I should probably proof read my responses ;)
Thanks for the detailed answer. It wasn’t clear for me neither how the override of variables should be performed. Maybe a bit of documentation on this regard is required.
It is a bit hard to find, but it is documented here: http://quasar-framework.org/guide/quasar-theming.html#Structure :)