-
<script lang="ts">
import ChildComponent from './ChildComponent.svelte';
import type { ComponentProps } from 'svelte';
const { ...props }: ComponentProps<typeof ChildComponent> = $props();
</script>
<ChildComponent {...props} /> When having something like the above, how do I add a class to Since |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Mar 29, 2025
Replies: 1 comment
-
Objects and arrays are flattened by <ChildComponent {...props} class={['new-class', props.class]} /> (You can also split off the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Vulcagon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Objects and arrays are flattened by
clsx
, so if the component uses the class prop "correctly", you should be able to do:(You can also split off the
class
if you want to switch the order.)