Skip to content

Svelte better global CSS handling idea #14578

@Loizzus

Description

@Loizzus

Describe the problem

I am a front end developer and I love Svelte (been using it for years). The only (minor) issue I have is with the way the global CSS is done. Having styles in each +page.svelte file is fantastic, and I would like it to be that good for global styles as well.

Having to wrap every class in :global() is clunky and ugly and makes the code non standard.
In practice what I do on my large projects is use .css files, one for each section. The difficulty with this is then when navigating between sections of the site that have different .css files, each link needs the data-sveltekit-reload property or other workarounds to remove the old classes before loading the new ones.

Describe the proposed solution

Ideally every +layout.svelte <style> section will apply that CSS to every file on the same level or in a sub directory to it. That way we will have targeted globals.

So in the image below the CSS in +layout.svelte would only apply to everything in the portal folder and every sub route such as /portal/times
image

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions