diff --git a/docs/src/pages/components/Tabs.svx b/docs/src/pages/components/Tabs.svx index 19f1e72f..bf6340f7 100644 --- a/docs/src/pages/components/Tabs.svx +++ b/docs/src/pages/components/Tabs.svx @@ -33,6 +33,14 @@ components: ["Tabs", "Tab", "TabContent", "TabsSkeleton"] +### Re-rendering tabs + +Use the [`#key` block](https://svelte.dev/docs#key) to dynamically update tab items or content. + +The example below shows tabs and the bound `selected` index being programmatically updated. + + + ### Skeleton \ No newline at end of file diff --git a/docs/src/pages/framed/Tabs/TabsDynamic.svelte b/docs/src/pages/framed/Tabs/TabsDynamic.svelte index 59344d8d..7af795c3 100644 --- a/docs/src/pages/framed/Tabs/TabsDynamic.svelte +++ b/docs/src/pages/framed/Tabs/TabsDynamic.svelte @@ -1,5 +1,12 @@ + + {#key tabs} {#each tabs as tab (tab.title)} @@ -37,6 +50,34 @@ Selected index: {selected} -{#each tabs as { title } (title)} - Toggle {title} tab -{/each} + + + {#each tabs as { title } (title)} + + Toggle + {title} + tab + + {/each} + + + + + + Set selected to 1 + +
Selected index: {selected}