-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CSS Variables: allow styling of ng-Bootstrap by their host angular components css file #2564
Comments
Wouldn't it be possible for the team to change the component encapsulation mode for the styles and import bootstrap styles in the components scss files for getting the correct rendering. https://angular.io/api/core/Component#encapsulation wouldn't this allow us to change the styles without needing use /deep/ ? |
Changing the encapsulation mode would, I believe, allow for external changes. But this is akin to using all global variables, and make it quite difficult to keep Global styles from unintended affects. I have also had some "leaking" (CSS values, affecting other components during modal window navigation) issues with my own components where I have set the encapsulation to none. |
In my opinion I think this is what I would want and expect when using a style framework like Bootstrap :) This way 'themes' can easily downloaded and applied for example. would it be possible to have it programmatically change the encapsulation? |
This is basically the only reason why I haven't started using this library yet. What I came up with for now is to
What this does is all components are still packaged with a compiled CSS, so you can pick up the library and use it off the shelf.
or if utilizing within a component, the If overriding variables for bootstrap that you want shared across all components, you can split Kind of long-winded, but figured I'd share. |
Should this be closed? I cannot follow @CharlyRipp's approach, I've checked the ng-bootstrap version: |
It has been a couple of years since I first logged this issue. I am now using a higher version of ng-bootstrap in a project that uses scss. I have not explicitly checked that the accordion background can be changed with the newer version setup. I will try and do that, and get back. |
Thanks @redevill. I have tried this with the latest version of ng-bootstrap. There are no |
Does not look like anything has changed in the last almost 5 years. It still can't be styled, and the powers at be close these issues without a thought. The reason I opened this Feature request was to give a legit method by which this need could be addressed, and not the bogus "View Encapsulation Turned off" which is NOT a solution. Equivalent to saying you must use Global variables only! - Ridiculous. this has been an issue back to 2016 - #1107 |
Feature Request description:
Styling ng-Bootstrap widgets can be a challenge.
Especially with /deep/ ::shadow being deprecated.
By using CSS variables in the bootstrap styling, consumers of the widgets (i.e. Other angular components, with ViewEncapsulation enabled) could then specify override values for these CSS variables.
Just think, in the local CSS for your component, you could specify a CSS variable value for the background color of the ngb-accordion, and it would set it 'accordingly' ;0
See Excerpt below:
https://developers.google.com/web/updates/2016/02/css-variables-why-should-you-care?hl=en
"This technique is especially useful for theming Web Components that use Shadow DOM, as custom properties can traverse shadow boundaries. A Web Component author can create an initial design using fallback values, and expose theming “hooks” in the form of custom properties."
The text was updated successfully, but these errors were encountered: