You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/context-api/Tab.html

17 lines
380 B

<script>
import { getContext, onDestroy } from 'svelte';
import { TABS } from './Tabs.html';
const tab = {};
const { registerTab, unregisterTab, selectTab, selectedTab } = getContext(TABS);
registerTab(tab);
onDestroy(() => {
unregisterTab(tab);
});
</script>
<button class:selected="{$selectedTab === tab}" on:click="{() => selectTab(tab)}">
<slot></slot>
</button>