mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
docs(Search): add reactive example
This commit is contained in:
parent
e0740a5f94
commit
9c710e9e9e
2 changed files with 39 additions and 0 deletions
|
@ -13,6 +13,10 @@ The `Search` component size is extra-large by default. There are [large](#large-
|
|||
|
||||
<Search placeholder="Search catalog..." value="Cloud functions" />
|
||||
|
||||
### Reactive example
|
||||
|
||||
<FileSource src="/framed/Search/SearchReactive" />
|
||||
|
||||
### Light variant
|
||||
|
||||
<Search light />
|
||||
|
|
35
docs/src/pages/framed/Search/SearchReactive.svelte
Normal file
35
docs/src/pages/framed/Search/SearchReactive.svelte
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue