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

[CSS isolation] attributes do not apply to components generated in code #342

Open
xperiandri opened this issue Nov 30, 2023 · 3 comments
Open

Comments

@xperiandri
Copy link
Contributor

If I do

let view (localizer : IStringLocalizer<Strings>) model dispatch = concat {
    comp<PageTitle> { localizer["CreateAccountPageTitle"] }
    lazyComp
        (fun model -> comp<EditForm> {
            "Model" => model
            attr.callback "OnValidSubmit" (fun (ctx : EditContext) -> FillAccount |> dispatch)
            attr.fragmentWith "ChildContent"

and

override _.CssScope = CssScopes.CreateAccountPage

then CSS isolation attributes are not applied to the form

@Tarmil
Copy link
Member

Tarmil commented Nov 30, 2023

Yes, that's how CSS isolation works in Blazor by default: it only applies to the elements directly inside the component, and not the ones in a nested component. To apply to all nested elements, you need to use the "deep" pseudo-element. So instead of this:

.some-element-inside-edit-form {
    color: red;
}

you can do:

::deep .some-element-inside-edit-form {
    color: red;
}

See https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation#child-component-support

@xperiandri
Copy link
Contributor Author

But I use Bolero components in a different way.
I have a derived type that works as a page used from C# project

@xperiandri
Copy link
Contributor Author

So it was a root level component

@xperiandri xperiandri changed the title CSS isolation attributes do not apply to components generated in code [CSS isolation] attributes do not apply to components generated in code Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants