mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
docs(toggle): add reactive example
This commit is contained in:
parent
7149fc5f12
commit
72ac7192ae
2 changed files with 26 additions and 0 deletions
|
@ -15,6 +15,10 @@ components: ["Toggle", "ToggleSkeleton"]
|
|||
|
||||
<Toggle labelText="Push notifications" toggled />
|
||||
|
||||
### Reactive example
|
||||
|
||||
<FileSource src="/framed/Toggle/ToggleReactive" />
|
||||
|
||||
### Custom labels
|
||||
|
||||
<Toggle labelText="Push notifications" labelA="No" labelB="Yes" />
|
||||
|
|
22
docs/src/pages/framed/Toggle/ToggleReactive.svelte
Normal file
22
docs/src/pages/framed/Toggle/ToggleReactive.svelte
Normal file
|
@ -0,0 +1,22 @@
|
|||
<script>
|
||||
import { Toggle, Button } from "carbon-components-svelte";
|
||||
|
||||
let toggled = true;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin-top: var(--cds-spacing-05);
|
||||
}
|
||||
</style>
|
||||
|
||||
<Toggle labelText="Push notifications" bind:toggled />
|
||||
|
||||
<div>
|
||||
<Button size="small" on:click="{() => (toggled = !toggled)}">
|
||||
Toggle
|
||||
{toggled ? 'off' : 'on'}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div>Toggled: {toggled}</div>
|
Loading…
Add table
Add a link
Reference in a new issue