-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple themes (light/dark) #1384
Comments
You can have component themes. Some components, like the checkbox or the input group have a property on their Sass theme function called $variant. The default variant is set to 'dark', but can also be set to 'light'. For instance, to create a checkbox theme, that will lay against dark backgrounds, you can do: // define your checkbox theme somewhere
$dark-cbx-theme: igx-checkbox-theme($variant: 'light', fill-color: #fff);
// If you want target support for post-IE11 browsers that have css variables support
// pass the theme you defined to the igx-css-vars mixin
:root { // make sure to scope the mixin as it spews out css variables
@include igx-css-vars($dark-cbx-theme);
}
// OR
// If you want to support for IE11 you have to use the component styles
// mixin and pass the theme to that
@include igx-checkbox($dark-cbx-theme); In both cases, be mindful of how View Encapsulation works in Angular. Let me know if you have any questions. To get what properties can be passed to different themes, you have to build the Sass documentation we bundle with this project. To build, clone this repo then run: $ npm run build:sassdoc The documentation will be generated in dist/docs/sass. |
I made a little mistake when typing this out. It should've been: // define your checkbox theme somewhere
$dark-cbx-theme: igx-checkbox-theme($variant: 'light', $fill-color: #fff); As to your second question. You have to clone the repository. Do not try to build from the installed package, it won't work. What part is confusing to you? |
Forgot to ask, what version of ignite ui for angular are you using? The above snippet works only on v 6.0. |
You can easily scope the themes to different parent selectors. Say something like: .dark-theme {
@include igx-checkbox($dark-cbx-theme);
}
.light-theme {
@include igx-checkbox($light-cbx-theme);
} Then you can conditionally switch the class on the parent component based on user settings. Btw, you can still use light and dark themes in 5.3; The property you pass there is |
Perfect. I'll try this out. Thanks for the assistance. |
@simeonoff Sorry for reopening this issue, but I still can't get this to work. So I have set up the following simple test: I would then expect that the colors would be applied to all components, as this is the global theme, but this doesn't seem to happen Also, how are you suppose to apply background colors to the global theme? |
@Eralmidia It's difficult to judge from the screenshots, but are you trying to implement this in a component? If so, you have to consider how View Encapsulation works in Angular. Depending on your use case, you have to either turn off the View Encapsulation in your component by adding: encapsulation: ViewEncapsulation.None to your component decorator configuration, or if you want to preserve View Encapsulation you have to nest your class selectors in :host ::ng-deep {
.light-theme { ... }
} |
@simeonoff Yes, I'm aware of the view encapsulation in Angular, and no, it's not for a specific component. What I'm after is to create several global themes (affecting all types of components). Our application consist of 3 main modules, where each has its own color (this is reflected in the primary/secondary colors). In addition to that, for each theme, you can choose a light (dark font on light background) or dark (light font on dark background) variant. What I want is basically what is implemented for the material2 project: As you can see, where ignite has the igx-theme function, material provides mat-light-theme and mat-dark-theme functins in order to define a light or dark theme |
@Eralmidia I've prepared a sample for you, it uses igniteui-angular version 6.0.0 as this is our current version. Please note that our theming engine is centered around components and component themes, and less so around having just one global theme with a few predefined color palettes. That being said, I understand we are lacking a lot in documentation right now, but we should have something a lot more comprehensive that covers more scenarios as soon as possible. Meanwhile, I will try to provide as much help and guidance I can. Here's the sample I was talking about: Let me know if you have any further questions. |
@simeonoff Thank's for the support. I do agree that this is mostly a matter of improving the documentation. The setup in the sample seems quite nice, and does what I would like to accomplish. A couple of questions tho:
|
The button doesn't need a custom theme as its text is always gonna be visible and the colors it uses are assumed from the scoped igx-theme. Had I created a new button theme and included it in the theme
|
|
You don't have to be actively using GitHub to build the docs. You just download the .zip for your version from the https://github.com/IgniteUI/igniteui-angular/releases, then cd into the unzipped directory and do. $ npm install && npm run build:docs The docs will be generated in |
@simeonoff Thanks a lot for great support. I was successfully able to apply a dark theme for the navdrawer, so this seems to work fine now. |
I really like the power of this system. Granted the theme file will be alot bigger than for instance material2, but it gives a lot of freedom. Well done. Just wanted to point out what might be a small error in the docs: This is the third param for the tabs theme. Seems like the property name describes background, but the description talks about text color. |
@Eralmidia Thanks, I will take care of it. |
Description
A question regarding themes:
In our application, users can choose between a light and dark theme. How do you go about doing this for igx? The themes documentations states "So we have themes for each component, and a global one, that styles the entire application and every component in it". Does this mean that we can only have a single global theme?
The text was updated successfully, but these errors were encountered: