Skip to content
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

Suggestion: @style directive similar to scoped CSS files #10766

Open
EliasStar opened this issue Aug 20, 2024 · 0 comments
Open

Suggestion: @style directive similar to scoped CSS files #10766

EliasStar opened this issue Aug 20, 2024 · 0 comments
Labels
area-compiler Umbrella for all compiler issues concept-language.design
Milestone

Comments

@EliasStar
Copy link

EliasStar commented Aug 20, 2024

In Blazor we have the ability to create scoped CSS files by ending the file in .razor.css.
For example a component named MyComponent.razor can have a isolated CSS file MyComponent.razor.css.
More details here.

This feature fits nicely when one creates components with a code-behind file (e.g. MyComponent.razor.cs).
But it feels odd when using the @code directive, so everything is grouped in a single file.

Therefore, I suggest a complementary @style directive which in essence behaves in the same way the isolated CSS files do. Meaning the code within should be bundled the same way and also respect DisableScopedCssBundling and ScopedCssEnabled project settings.

I have not looked into the inner workings of Razor and do not know how the compilation and bundling works in detail. However a naive solution could be to just emit the CSS in the @style directive as scoped files and then just use the existing bundling logic.

@davidwengier davidwengier added area-compiler Umbrella for all compiler issues concept-language.design labels Aug 20, 2024
@chsienki chsienki added this to the Backlog milestone Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues concept-language.design
Projects
None yet
Development

No branches or pull requests

3 participants