docs(Search): add reactive example

This commit is contained in:
Eric Liu 2020-12-05 14:40:41 -08:00
commit 9c710e9e9e
2 changed files with 39 additions and 0 deletions

View file

@ -13,6 +13,10 @@ The `Search` component size is extra-large by default. There are [large](#large-
<Search placeholder="Search catalog..." value="Cloud functions" /> <Search placeholder="Search catalog..." value="Cloud functions" />
### Reactive example
<FileSource src="/framed/Search/SearchReactive" />
### Light variant ### Light variant
<Search light /> <Search light />

View file

@ -0,0 +1,35 @@
<script>
import { Search, ButtonSet, Button } from "carbon-components-svelte";
let value = "";
</script>
<style>
div {
margin-top: var(--cds-spacing-05);
}
</style>
<Search bind:value />
<div>
<ButtonSet>
<Button
size="small"
disabled="{value === 'Cloud functions'}"
on:click="{() => (value = 'Cloud functions')}"
>
Set value
</Button>
<Button
kind="ghost"
size="small"
disabled="{value.length === 0}"
on:click="{() => (value = '')}"
>
Clear value
</Button>
</ButtonSet>
</div>
<div>Value: {value}</div>