Open
Description
When using the directive class={someVariableWithTheClassName}
, it fails because the generated css class will have a hash, but the applied class won't.
- This works perfectly:
<script lang="ts">
export let black: boolean;
export let white: boolean;
</script>
<button class:black={backgroundColor === 'black'} class:white={backgroundColor === 'white'} />
<style module>
.white {
background-color: #fff;
}
.black {
background-color: #000;
}
</style>
- This fails because the class "black" will have the hash, but the svelte app applies the name without the hash.
<script lang="ts">
export let bgColor: 'white' | 'black';
</script>
<button class={bgColor} />
<style module>
.white {
background-color: #fff;
}
.black {
background-color: #000;
}
</style>