0
votes

I'm trying to set up a project in Sapper (with Svelte).

I want to use the Materialize CSS framework and JS components in my project.

How could I set this up?

1

1 Answers

0
votes

Run npm i -D materialize-css (and npm i -D @types/materialize-css if using typescript)

Then just add

import 'materialize-css/dist/js/materialize.min.js'
import 'materialize-css/dist/css/materialize.min.css'
...
M.AutoInit();

to src/client.js

and

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

to src/template.html

EDIT: If using typescript, add

"compilerOptions": {"types": ["materialize-css", "svelte"]}

to tsconfig.json

Original Reddit comment answer