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/packages/svelte/test/runtime-browser/custom-elements-samples/reflect-attributes-add-remove/main.svelte

24 lines
384 B

<svelte:options
customElement={{
tag: 'custom-element',
props: {
expanded: { reflect: true, type: 'Boolean', attribute: 'aria-expanded' }
}
}}
/>
<script>
export let expanded = false;
</script>
<div>
<button on:click={() => (expanded = !expanded)}>Toggle</button>
<div class:hidden={!expanded}>Hidden Text</div>
</div>
<style>
.hidden {
display: none;
}
</style>