Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zraly committed Jun 9, 2022
1 parent 7f0126e commit d8a0a71
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,7 @@ npm i mistral-ui

## Usage

### Static HTML components

Just copy & paste into your HTML.

```html
<span class="text-neutral">badge</span>
```

### Dynamic components using Alpine.js

Import component into your man js file:

```javascript
import Alpine from 'alpinejs'

// If you want to use the Multiselect component:
import { multiselect } from 'mistral-ui'
Alpine.data('multiselect', multiselect);

window.Alpine = Alpine
Alpine.start();
```

Copy & paste the HTML form the [component detail page](https://mistralui.com/component-multiselect):
Add a `x-data` attribute to your element:

```html
<select multiple x-data="multiselect">
Expand All @@ -48,4 +25,32 @@ Copy & paste the HTML form the [component detail page](https://mistralui.com/com
<option value="Berlin">Berlin</option>
</optgroup>
</select>
```

### via CDN

1. Put this script tag into your head section:

```html
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
```

2. Initialize desired component via Alpine's `alpine:init` event:

```javascript
document.addEventListener('alpine:init', () => {
Alpine.data('multiselect', Mistral.multiselect)
})
```

### via NPM

1. Import component into your man js file:

```javascript
import Alpine from 'alpinejs'
import { multiselect } from 'mistral-ui'

Alpine.data('multiselect', multiselect);
Alpine.start();
```

0 comments on commit d8a0a71

Please sign in to comment.