Here is one way to approach the task. Utilizing a backdrop that reacts when clicked upon. Does this align with your expectations?
MainComponent.vue
<template>
<div id="app" class="backdrop" @click.self="showBox = !showBox">
<img alt="Vue logo" src="./assets/logo.png" width="25%" />
<HelloWorld :showBox="showBox" msg="Hello Vue in CodeSandbox!" />
</div>
</template>
<script>
import HelloWorld from "./components/HelloWorld";
export default {
name: "MainComponent",
components: {
HelloWorld,
},
data: function () {
return {
showBox: true,
};
},
};
</script>
<style>
#app {
text-align: center;
margin-top: 40px;
}
.backdrop {
z-index: 0;
position: fixed;
width: 100%;
height: 100%;
}
</style>
HelloWorldComponent.vue
<template>
<div>
<div v-if="showBox" class="wrapper"></div>
</div>
</template>
<script>
export default {
name: "HelloWorldComponent",
props: {
msg: String,
showBox: Boolean,
},
};
</script>
<style scoped>
.wrapper {
width: 300px;
height: 150px;
background: green;
margin: auto;
}
</style>