# svelte-bulma-forms

> Bulma form components for Svelte.js

Latest version **0.1.3** (published 2019-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-bulma-forms
pnpm add svelte-bulma-forms
yarn add svelte-bulma-forms
bun add svelte-bulma-forms
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-01-22 |
| First published | 2018-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 341.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Elco Brouwer von Gonzenbach |
| Maintainers | elcobvg |
| Keywords | javascript, svelte, bulma, forms, svelte-components, ui, validation |

## Links

- npm: https://www.npmjs.com/package/svelte-bulma-forms
- Repository: https://github.com/elcobvg/svelte-bulma-forms
- Homepage: https://github.com/elcobvg/svelte-bulma-forms#readme
- Issues: https://github.com/elcobvg/svelte-bulma-forms/issues
- npm.io page: https://npm.io/package/svelte-bulma-forms

## Dependencies (1)

- [random-uuid-v4](https://npm.io/package/random-uuid-v4.md) ^0.0.7

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2019-01-22
- 0.0.2 (beta) — 2018-07-11
- 0.1.2 — 2018-10-19
- 0.1.1 — 2018-07-19
- 0.1.0 — 2018-07-17
- 0.0.12 — 2018-07-16
- 0.0.11 — 2018-07-16
- 0.0.10 — 2018-07-14
- 0.0.9 — 2018-07-13
- 0.0.8 — 2018-07-13
- 0.0.7 — 2018-07-13
- 0.0.6 — 2018-07-13
- 0.0.5 — 2018-07-12
- 0.0.4 — 2018-07-12
- 0.0.3 — 2018-07-11
- … 1 more at https://npm.io/package/svelte-bulma-forms/versions

## README

# svelte-bulma-forms
Bulma form components for [Svelte.js](https://svelte.technology/)

These components offer a convenient way to build HTML forms, either in **Svelte** projects or in **plain JavaScript.**

**Features**

* all form elements as defined in Bulma
* built-in basic input validation, easily extendable
* controls and fields emit events for your app to hook into

#### Demo at http://svelte-bulma-forms.surge.sh/


## Install

`npm install svelte-bulma-forms`

## Use

Import the components you need in your Svelte project.

````javascript
import {
  TextField,
  DateField,
  EmailField
} from 'svelte-bulma-forms/module'

export default {
  components: {
    TextField,
    DateField,
    EmailField,
  ...
  }
}
````
And then use them like so:

````html
<TextField name="name" label="Name" horizontal />

<CheckboxGroup horizontal>
  <CheckboxControl name="agree" required>
    I agree to the <a href="#">terms and conditions</a>
  </CheckboxControl>
</CheckboxGroup>

<ButtonField state="info" type="submit" horizontal />
````
**Don't forget to include the Bulma and Font Awesome CSS files!**

For including styles, you can either place the below styles in the `<head>` of your template:

````html
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
````

Or you can import them to your webpack/rollup entry point:

````javascript
require('/path/to/node_modules/bulma/css/bulma.min.css')
require('/path/to/node_modules/font-awesome/css/font-awesome.min.css')
````

**Note that you'll have to install** `bulma` **and** `font-awesome` **first**

## Available elements

### Form fields

**Form fields** are composite components offering the most convenient way to build forms. The following fields are available:

- `AutoCompleteField`
- `ButtonField`
- `DateField`
- `EmailField`
- `FileField`
- `PasswordField`
- `PasswordMaskField`
- `SelectField`
- `TextareaField`
- `TextField`

See [**form fields**](https://github.com/elcobvg/svelte-bulma-forms/tree/master/src/fields)

### Form controls

In cases where you may wish to use **form input fields** by themselves, you can use [**form controls**](https://github.com/elcobvg/svelte-bulma-forms/tree/master/src/controls). The following controls are available:

- `AutoCompleteControl`
- `ButtonControl`
- `CheckboxControl`
- `FileControl`
- `InputControl`
- `MultiSelectControl`
- `RadioControl`
- `SelectControl`
- `TextareaControl`

### Form groups

Controls like **checkboxes** and **radio buttons** need to be grouped together. There is also a group for regular inputs and grouped **buttons**:

- `CheckboxGroup`
- `InputGroup`
- `RadioGroup`

See [**form groups**](https://github.com/elcobvg/svelte-bulma-forms/tree/master/src/groups)

## Further information

### Events
Each input element emits a `change` event with its `value` on input change, which you can use in your app according to your needs.

### Custom input validation
In addition to the built-in default input validation, you can supply your own validation rules and messages. Read all about it in the [**validation documentation**](https://github.com/elcobvg/svelte-bulma-forms/tree/master/src/validation)


## Made with Svelte
It's made with [Svelte](https://svelte.technology/), which means you don't need any JS framework. Just use the file in the `dist` directory in any Javascript project:

**include the bundle:** 

````html
<script src="svelte-bulma-forms/dist/index.js"></script>
````
**create components like so:**

````javascript
const { EmailField } = SvelteBulmaForms

const emailInput = new EmailField({
  target: document.querySelector('#email'),
  data: { 
    name: 'email',
    label: 'Email address',
    horizontal: true
  }
})
````
### See also

- https://github.com/elcobvg/svelte-bulma-components a collection of Bulma UI components
- https://github.com/elcobvg/svelte-autocomplete lightweight autocomplete component, without the Bulma styling

### Reference

- https://bulma.io/documentation/form/general
- https://svelte.technology/guide
- https://fontawesome.com/v4.7.0/

---
_Source: https://npm.io/package/svelte-bulma-forms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
