Svelte – Slots

0 min read


Alright guysss… welcome back again to Svelte channel… sekarang kita masuk ke materi Component Composition ya … mari kita coba dan praktekkan bersama… let’s GOOO

pertama buat file SlotsComp.svelte

<div class="box">
	<slot></slot>
</div>

<style>
	.box {
		width: 300px;
		border: 1px solid #aaa;
		border-radius: 2px;
		box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
		padding: 1em;
		margin: 0 0 1em 0;
	}
</style>

dan buat kembali file Slots.svelte

<script>
	import Box from './slots/SlotsComp.svelte';
</script>

<Box>
	<h2>Hello!</h2>
	<p>This is a box. It can contain anything.</p>
</Box>

dan import ke App.svelte

	<LongpressActions />
	<PannableActions />
	<ClassDirective />
	<ShortHand />
	<Slots />

</main>

dan hasilnya seperti ini guyss..

Okay mantabs…. link github ada disini …. sampai jumpaa cyaaaa…

Bima Sena

Leave a Reply

Your email address will not be published. Required fields are marked *