mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
docs(content-switcher): add reactive example
This commit is contained in:
parent
3d5eed849c
commit
d1565c5f75
2 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
|||
<script>
|
||||
import {
|
||||
ContentSwitcher,
|
||||
Switch,
|
||||
ButtonSet,
|
||||
Button,
|
||||
} from "carbon-components-svelte";
|
||||
|
||||
let selectedIndex = 1;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin-top: var(--cds-spacing-05);
|
||||
}
|
||||
</style>
|
||||
|
||||
<ContentSwitcher bind:selectedIndex>
|
||||
<Switch text="Latest news" />
|
||||
<Switch text="Trending" />
|
||||
<Switch text="Recommended" />
|
||||
</ContentSwitcher>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
size="small"
|
||||
disabled="{selectedIndex === 2}"
|
||||
on:click="{() => (selectedIndex = 2)}"
|
||||
>
|
||||
Set selected to 2
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div>Selected index: {selectedIndex}</div>
|
Loading…
Add table
Add a link
Reference in a new issue