# sweet-modal-vue-3

> SweetModal library for use with Vue 3, Nuxt 3

Latest version **1.0.0** (published 2024-09-23) · 0 weekly downloads

## Install

```sh
npm install sweet-modal-vue-3
pnpm add sweet-modal-vue-3
yarn add sweet-modal-vue-3
bun add sweet-modal-vue-3
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-09-23 |
| First published | 2022-03-06 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 60.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Festus Iyere |
| Maintainers | festusiyere |
| Keywords | sweetmodal, sweet-modal, modal, vue, vite, vue 3, nuxt 3, nuxt3, vue3, library |

## Links

- npm: https://www.npmjs.com/package/sweet-modal-vue-3
- Repository: https://github.com/festusiyere/sweet-modal-vue-3
- Homepage: https://github.com/festusiyere/sweet-modal-vue-3#readme
- Issues: https://github.com/festusiyere/sweet-modal-vue-3/issues
- npm.io page: https://npm.io/package/sweet-modal-vue-3

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^3.2.45

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-09-23
- 0.3.0 — 2023-06-15
- 0.0.1 — 2022-03-06

## README

# SweetModal

This library is a fork from [vue sweet modal](https://github.com/visma-meglerfront/sweet-modal-vue) for Vue 3 and Nuxt 3

## Usage

Install SweetModal for Vue.js through npm:

```
npm install sweet-modal-vue-3
```

Install SweetModal for Vue.js through yarn:

```
yarn add sweet-modal-vue-3
```

# Usage/Examples

## For Vue 3
### Use Globally

```javascript
import { createApp } from 'vue'

const app = createApp({})

app.component(SweetModal)
app.mount('#app')
```

or

```javascript
import SweetModal from 'sweet-modal-vue-3'
import App from './App.vue'

const app = createApp(App)

app.component(SweetModal)
app.mount('#app')
```

### Use per Component

```javascript
import { SweetModal, SweetModalTab } from 'sweet-modal-vue-3'

{
	components: {
		SweetModal,
		SweetModalTab
	}

	...
}
```

### Using SFC and TypeScript

```typescript
import { SweetModal, SweetModalTab } from 'sweet-modal-vue-3'

const modal = ref<InstanceType<typeof SweetMOdal> | null>(null)

const openModal = () => {
	modal.value?.open()
}

const closeModal = () => {
	modal.value?.close()
}
```

## For Nuxt 3

### Use Globally

```javascript
import SweetModal from 'sweet-modal-vue-3'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.component('SweetModal', SweetModal)
})

```

### Using SFC and TypeScript
If you are experiencing a typescript error when using SweetModal in Nuxt 3, you can create a global type or custom type

```typescript
  class SweetModalComponent extends Vue {
    open(tabId: string): void
    close(): void
  }

  type SweetModalType = InstanceType<typeof SweetModalComponent>
```

```typescript
import { SweetModal, SweetModalTab } from 'sweet-modal-vue-3'

const modal = ref<SweetModalType>()

const openModal = () => {
	modal.value?.open()
}

const closeModal = () => {
	modal.value?.close()
}
```

## Browser Compatibility

SweetModal should work in most major browsers:

-   Safari 9+
-   Firefox 20+
-   Chrome 20+
-   Opera 15+
-   Microsoft Edge

## Contribution

1. Fork the repository
2. Run `yarn`
3. Run `yarn dev` and start hacking. You can reach the example site at `http://localhost:3000`.
4. When you're done, run one final `yarn build` command and commit your work for a pull request.

### Guidelines

-   tabs for indentation, 1 tab = 4 spaces
-   camelCase method names
-   \_camelCase for private methods
-   snake_case computed properties
-   snake_case data
-   kebab-case attributes
-   arrow functions if possible
-   be fully ES6 compliant!

---
_Source: https://npm.io/package/sweet-modal-vue-3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
