I am using sveltekit with tailwind-css
I want to be able to pass some behavior thru variables to the element
<script>
export let primary = 'fnt-blue-500';
export let accent = 'fnt-green-500';
export let translate_dir = '-translate-x';
export let translate_amount = 1;
let translate = translate_dir + '-' + translate_amount;
</script>
<button
id="1"
class="flex items-center justify-center py-2 pl-1 pr-1 shadow-inner duration-200 hover:cursor-pointer active:text-white bg-{accent} active:bg-{primary} hover:{translate} active:{translate}"
>
<slot>Button</slot>
</button>
I tried a templatestring with all classes in them but that didnt work either
let template = `items-center justify-center py-2 pl-1 pr-1 shadow-inner duration-200 hover:cursor-pointer active:text-white bg-${accent} active:bg-${primary} hover:${translate} active:${translate}`
In the browser the element has this as class:
<button id="1" class="flex items-center justify-center py-2 pl-1 pr-1 shadow-inner duration-200 hover:cursor-pointer active:text-white bg-fnt-green-500 active:bg-fnt-blue-500 hover:-translate-x-1 active:-translate-x-1">Optionen</button>
but the hover and active state still wont work
I dont understand why this is happening, does sombedoy know? Or another way to parse behavior?