Svelma is a set of UI components for Svelte based on the Bulma CSS framework.
$ npm install --save bulma svelma2
$ npm install node-sass svelte-preprocess rollup-plugin-postcss --save-dev
// rollup.config.js
import postcss from 'rollup-plugin-postcss'
import preprocess from 'svelte-preprocess'
// ...
export default {
// ...
plugins: [
svelte({
// ...
preprocess: preprocess()
}),
postcss(),
}
}
<!-- App.svelte -->
<script>
import 'bulma/css/bulma.css'
import { Button } from 'svelma2'
</script>
<button type="is-primary">I'm a Button!</button>
4. Include Font Awesome icons
From CDN in your HTML page:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" />
Or as an npm package imported into your root component:
$ npm install --save @fortawesome/fontawesome-free
<!-- App.svelte -->
<script>
import 'bulma/css/bulma.css'
import '@fortawesome/fontawesome-free/css/all.css'
</script>
If you are doing server-side rendering with Sapper, you'll need to import the .svelte files directly so that your app can compile them, rather than importing from the compiled module.
i.e.:
import Button from 'svelma/src/components/Button.svelte'
instead of
import { Button } from 'svelma2'
Much thanks to the Buefy and Svelma projects! It provided the inspiration and lots of code examples for this version of Svelma.