mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
docs(modal): add "Custom focus" example
This commit is contained in:
parent
3ef64fb7b3
commit
6acd0bf425
2 changed files with 35 additions and 0 deletions
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/Modal" />
|
<FileSource src="/framed/Modal/Modal" />
|
||||||
|
|
||||||
|
### Custom focus
|
||||||
|
|
||||||
|
By default, the modal close button will be focused when opened.
|
||||||
|
|
||||||
|
Use the `selectorPrimaryFocus` to specify the element that should be focused when the modal is opened (e.g., `#id`, `.class`, `[data-attribute]`).
|
||||||
|
|
||||||
|
<FileSource src="/framed/Modal/ModalCustomFocus" />
|
||||||
|
|
||||||
### Danger modal
|
### Danger modal
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/DangerModal" />
|
<FileSource src="/framed/Modal/DangerModal" />
|
||||||
|
|
27
docs/src/pages/framed/Modal/ModalCustomFocus.svelte
Normal file
27
docs/src/pages/framed/Modal/ModalCustomFocus.svelte
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<script>
|
||||||
|
import { Button, Modal, TextInput } from "carbon-components-svelte";
|
||||||
|
|
||||||
|
let open = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Button on:click="{() => (open = true)}">Create database</Button>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
bind:open
|
||||||
|
modalHeading="Create database"
|
||||||
|
primaryButtonText="Confirm"
|
||||||
|
secondaryButtonText="Cancel"
|
||||||
|
selectorPrimaryFocus="#db-name"
|
||||||
|
on:click:button--secondary="{() => (open = false)}"
|
||||||
|
on:open
|
||||||
|
on:close
|
||||||
|
on:submit
|
||||||
|
>
|
||||||
|
<p>Create a new Cloudant database in the US South region.</p>
|
||||||
|
<br />
|
||||||
|
<TextInput
|
||||||
|
id="db-name"
|
||||||
|
labelText="Database name"
|
||||||
|
placeholder="Enter database name..."
|
||||||
|
/>
|
||||||
|
</Modal>
|
Loading…
Add table
Add a link
Reference in a new issue