|
| 1 | +--- |
| 2 | +title: Override Theme Styles |
| 3 | +page_title: Override Theme Styles |
| 4 | +description: General rules of thumb to override UI for Blazor themes |
| 5 | +slug: themes-override |
| 6 | +tags: telerik,blazor,theme,override |
| 7 | +published: True |
| 8 | +position: 6 |
| 9 | +--- |
| 10 | + |
| 11 | +# Override Theme Styles |
| 12 | + |
| 13 | +Sometimes you may need to make a small change to the appearance of a component, while still using the same [built-in]({%slug general-information/themes%}) or [custom]({%slug themes-custom%}) theme. |
| 14 | + |
| 15 | +This article provides high-level guidance about the required knowledge and tools to override existing CSS styles without changing them. |
| 16 | + |
| 17 | +## CSS Knowledge |
| 18 | + |
| 19 | +To override an existing style, you implement another *conflicting* style. To make sure the new style takes precedence, it should have a **higher specificity**. |
| 20 | + |
| 21 | +* [MDN Documentation for CSS Specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity). You may prefer a [less formal explanation](https://www.smashingmagazine.com/2007/07/css-specificity-things-you-should-know/). |
| 22 | +* How to easily [calculate CSS Specificity](https://stuffandnonsense.co.uk/archives/images/css-specificity-wars.png) (part of the article [CSS Specificity Wars](https://stuffandnonsense.co.uk/archives/css_specificity_wars.html)). |
| 23 | + |
| 24 | +## Tools |
| 25 | + |
| 26 | +To see what CSS styles are applied on an HTML element, use the browser's developer tools. |
| 27 | + |
| 28 | +* [Inspect the HTML output of a page](https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools#inspect-the-generated-html-of-a-control) |
| 29 | +* [See the applied styles for a specific element](https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools#see-the-applied-styles) |
| 30 | +* [Inspect elements that hide automatically and disappear from the DOM](https://www.telerik.com/blogs/improve-your-debugging-skills-with-chrome-devtools-(part-2)#inspect-auto-hiding-tooltips-and-elements) |
| 31 | + |
| 32 | +## Blazor CSS Isolation |
| 33 | + |
| 34 | +[CSS isolation](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation) is a .NET feature, which scopes styles to a specific Razor component. |
| 35 | + |
| 36 | +* There are two cases when CSS isolation may not work with UI for Blazor components. We explain the reasons and suggest workarounds in [this knowledge base article]({%slug common-kb-css-isolation%}). The two cases are: |
| 37 | + * Using isolated styles with a component `Class`. |
| 38 | + * Using isolated styles for popups (Window, Dialog). |
0 commit comments