Skip to content
kd
18 Feb 2022
Back to blog

Sveltekit tailwind starter

1 min read (57 words)

Table of contents

The following is minimal instructions for getting started with the SvelteKit skeleton app, with tailwind and font awesome support. Run the following and follow prompts:

Terminal window
npm init svelte@next
npx svelte-add@latest tailwindcss
npx svelte-add@latest scss
npx svelte-add@latest postcss

Install all the following packages:

Terminal window
npm install
npm install -D @tailwindcss/forms
npm install -D tailwindcss/typography
npm install -D svelte-icons
npm install -D @fortawesome/free-solid-svg-icons@5.15.4
npm install -D @fortawesome/free-regular-svg-icons@5.15.4
npm install -D @fortawesome/free-brands-svg-icons@5.15.4
npm install -D @sveltejs/adapter-static@next
npm install layercake
npm install tw-elements
npm install d3

Add the following to .prettierrc:

{
"useTabs": false,
"quoteProps": "preserve",
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"bracketSameLine": false,
"bracketSpacing": true
}

And run the following to format all files:

Terminal window
prettier . --write --ignore-path .gitignore

tailwind-elements

If you want to add tailwind-elements, change tailwind.config.js to the following:

const config = {
content: ["./src/**/*.{html,js,svelte,ts}", "./node_modules/tw-elements/dist/js/**/*.js"],
theme: {
extend: {},
},
plugins: [
require("@tailwindcss/forms"),
require("@tailwindcss/typography"),
require("tw-elements/dist/plugin"),
],
};
module.exports = config;

And update __layout.svelte to include the following:

<script lang="ts">
import "../app.css";
import { browser } from "$app/env";
import { onMount } from "svelte";
onMount(async () => {
if (browser) {
await import("tw-elements");
}
});
</script>

Citation

@online{krishnamurthy2022sveltekittailwindstarter,
  author = {Dheepak Krishnamurthy},
  title = {Sveltekit tailwind starter},
  year = {2022},
  date = {2022-02-18},
  url = {https://kdheepak.com/blog/sveltekit-tailwind-starter/},
  langid = {en},
}

For attribution, please cite this work as:

Dheepak Krishnamurthy, "Sveltekit tailwind starter", February 18, 2022 https://kdheepak.com/blog/sveltekit-tailwind-starter/


Compiling firmware for the Moonlander keyboard with QMK
Using Tikz with Pandoc