mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
parent
6855633aec
commit
a828625c66
2 changed files with 24 additions and 1 deletions
|
@ -159,4 +159,12 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
|
|||
<Button size="lg" skeleton />
|
||||
<Button skeleton />
|
||||
<Button skeleton size="field" />
|
||||
<Button skeleton size="small" />
|
||||
<Button skeleton size="small" />
|
||||
|
||||
## Programmatic focus
|
||||
|
||||
Bind to the `ref` prop to access a reference to the underlying button element.
|
||||
|
||||
You can use this reference to programmatically focus the button.
|
||||
|
||||
<FileSource src="/framed/Button/ProgrammaticFocus" />
|
||||
|
|
15
docs/src/pages/framed/Button/ProgrammaticFocus.svelte
Normal file
15
docs/src/pages/framed/Button/ProgrammaticFocus.svelte
Normal file
|
@ -0,0 +1,15 @@
|
|||
<script>
|
||||
import { Button } from "carbon-components-svelte";
|
||||
|
||||
let ref;
|
||||
</script>
|
||||
|
||||
<Button bind:ref>Primary button</Button>
|
||||
<Button
|
||||
kind="ghost"
|
||||
on:click="{() => {
|
||||
ref?.focus();
|
||||
}}"
|
||||
>
|
||||
Click to focus the Primary button
|
||||
</Button>
|
Loading…
Add table
Add a link
Reference in a new issue