1.4.0 • Published 1 year ago
modal-svelte v1.4.0
Modal Svelte
Modal component for Svelte
Features:
- Autofocus
- Focus trapping
- Returns focus after closing
- Form mode
Install
npm install modal-svelteUsage
<script>
import Modal from 'modal-svelte'
</script>
<Modal title="Hello world!" onCancel={() => (open = false)}>
<p>Content</p>
</Modal>Functionality
This shows all available functionality
<Modal
title="Hello world!"
onCancel={() => (open = false)}
form={() => submitMyForm()}
noEscapeHandling
noCloseIcon
class="w-full"
>
<p>Content</p>
<input />
<!-- If you want to bring focus to a specific element -->
<input autofocus />
<div slot="buttons">
<button type="submit">Submit</button>
</div>
</Modal>:root {
--modal-bg: #fff;
color: #000;
}Dev instructions
Get started
- Install Node.js
- Run
npm install
Commands
npm run dev: Start in dev modenpm run build: Buildnpm run lint: Lintnpm run format: Format
Publish new version
- Update
CHANGELOG.md - Check for errors
npm run lint - Bump the version number
npm version --no-git-tag <version> - Generate the package
npm run build:package - Publish the package
npm publish - Commit with a tag in format "v#.#.#"
- Create GitHub release with release notes