-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
How can i bind class as array? #3328
Comments
Hi @ashnamuh In Svelte, you can put any JavaScript code between a pair of brackets. This allows you to achieve the functionality you want as follows:
Also, for future reference, please post your "How do I do <X> in Svelte?" questions in the Discord chatroom. GitHub is really more for Svelte-specific issues and bugs. Thanks! |
My code became full of <div class={[
'px-10 py-5',
$AB.black_friday ? 'bg-black' : 'bg-blue-100'
].join(' ')}
>
<h2 class={[
'text-2xl lg:text-4xl',
$AB.black_friday ? 'text-white' : 'text-blue-800'
].join(' ')}
>
Welcome to my website!
</h2>
</div> Using arrays in So I was wondering... Is it possible to create a Vite script (?) to "auto-join" array items in |
You could get on with template strings |
I tried
But result is
I expect
How can i bind multiple classes to a element?
The text was updated successfully, but these errors were encountered: