How can I override styles with incline classes with SvelteKit
See original GitHub issueIf I have something like
<h1 class="bg-green-800= bg-blue-400">Welcome to SvelteKit</h1>
The bg-green-800 class gets applied. It seems like classes are applied alphabetically, and not in the order in which they are defined.
This prevents me from doing a component that allows me to override styles, comething like this:
<script>
let className = '';
export { className as class };
export let label = 'Click me!';
</script>
<button class="bg-red-500 {className}">{label}</button>
It seems to be a problem with SvelteKit, because in this playground it works ok
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Advanced styling / The class directive • Svelte Tutorial
The selected class is added to the element whenever the value of the expression is truthy, and removed when it's falsy.
Read more >Routing • Docs • SvelteKit
For this, we add a +page.js (or +page.ts , if you're TypeScript-inclined) module that exports a load function: src/routes/blog/[slug]/+page.js.
Read more >Advanced styling / Inline styles • Svelte Tutorial
Great, now you can style the paragraph using variables that change based on your input without having to make a class for every...
Read more >Advanced styling / The style directive • Svelte Tutorial
The style directive shares a few qualities with the class directive. You can use a shorthand when the name of the property and...
Read more >Advanced routing • Docs • SvelteKit
Note that an optional route parameter cannot follow a rest parameter ( [...rest]/[[optional]] ), since parameters are matched 'greedily' and the optional ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@opensas thanks for your report. Actually I can’t reproduce it myself. Can you please add more information or give a minimal repro.
i dont understand why you want to overide it and not just like this