Skip to content

Commit 32bd1cb

Browse files
authored
Merge pull request #65 from Alhada06/main
add theme prop and watcher
2 parents fdd086d + ca50a8e commit 32bd1cb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

components/vue3/src/components/vue-particles.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</template>
44

55
<script setup lang="ts">
6-
import { nextTick, onMounted, onUnmounted } from "vue";
6+
import { nextTick, onMounted, onUnmounted, watch } from "vue";
77
import { type Container, type ISourceOptions, type Engine, tsParticles } from "@tsparticles/engine";
88
99
export type IParticlesProps = ISourceOptions;
@@ -14,6 +14,7 @@ const props = defineProps<{
1414
id: string;
1515
options?: IParticlesProps;
1616
url?: string;
17+
theme?: string;
1718
}>();
1819
1920
const emit = defineEmits<{
@@ -60,4 +61,12 @@ onUnmounted(() => {
6061
container.destroy();
6162
container = undefined;
6263
});
64+
65+
watch(
66+
() => props.theme,
67+
() => {
68+
container?.loadTheme(props.theme);
69+
},
70+
{ immediate: true, deep: true },
71+
);
6372
</script>

0 commit comments

Comments
 (0)