Skip to content

Commit

Permalink
Update rule.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jackreimers authored Oct 3, 2023
1 parent bb77903 commit 6afe82e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions rules/scoped-css/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors:
- title: Harry Ross
url: https://www.ssw.com.au/people/harry-ross
created: 2023-09-29T12:00:00.000Z
guid:
guid: 16300344-d1b7-4dbe-abfa-e8b18d8f0c8d
---

On large frontend projects with lots of components it's common to have issues with your CSS classes overwriting eachother or conflicting.
Expand Down Expand Up @@ -40,15 +40,14 @@ It also makes it much easier to change styling on individual components without

#### Benefits
* Can reuse class names in each component without conflicts
*

#### Disadvantages
* Styles have to be manually written

#### Blazor

In Blazor scoped CSS files are associated with components with dot syntax.
For example, if I have a component called `MyComponent.razor`, I can create a file called `MyComponent.razor.css` and the classes set in that file will only apply to `MyComponent`.
For example, if we have a component called `MyComponent.razor`, we can create a file called `MyComponent.razor.css` and the classes set in that file will only apply to `MyComponent`.

##### Inheritance

Expand All @@ -60,7 +59,7 @@ Blazor supports having scoped CSS classes inherited by child components.
</MyComponent>
```

In `MyComponent.razor.cs`, if I use the `::deep` psuedo selector on a class, it will be applied to `MyChildComponent`.
In `MyComponent.razor.cs`, if we use the `::deep` psuedo selector on a class, it will be applied to `MyChildComponent`.

```css
::deep .myClass {
Expand Down Expand Up @@ -115,5 +114,3 @@ This will then render the element with a component specific class, differentiate
```html
<h1 class="Component_heading__nEBhk">Bold Heading Here</h1>
```


0 comments on commit 6afe82e

Please sign in to comment.