Read if:
Introduction
One day, I was reading an article What is the need of having a design system
. They mentioned some crucial point to be noticed in the articles.
What is a Design System?
A design system is a collection of reusable components, guided by clear standards, that can be assembled together to build any number of applications.
If you are looking for Open Sourced Design Systems Click Here. This contains all big projects.
What is Tailwind CSS?
Tailwind CSS is basically a utility-first CSS framework for rapidly building custom user interfaces. It is a highly customizable, low-level CSS framework that gives you all of the building blocks you need to build bespoke designs without any annoying opinionated styles you have to fight to override.
If you are looking to use TailwindCSS Without SvelteKit, Visit TailwindCSS Docs. They explain everything in detail.
What is SvelteKit?
SvelteKit is an app framework (or 'metaframework') built on top of Svelte (which is a component framework). Its job is to make it easy to build Svelte apps with all the modern best practices like server-side rendering (SSR) and code-splitting.
Wanna learn more about SvelteKit? Visit SvelteKit Docs
Starting Your SvelteKit Demo Template
npm init svelte@next my-project
my-project
is the name you wanna give to your project in your system
When you run above command terminal will ask some question related to prettier
, typescript support
and etc, choose as per your need.
Above step created a dir in your system by the name my-project
. Now got your project directory and npm install all dependencies.
cd my-project && npm i
This command is going to install your all dependencies for the project. Now run your SvelteKit project to live dev server using
npm run dev
How do i know
what will npm run dev will do?
For that in your project root directory find a filepackage.json
and in this file there is a Dictionary by name of scripts. Read it and if you have any trouble ask in comment or google it.
This will do SvelteKit setup. Now we will see how to setup Tailwind CSS in this project.
Setting up Tailwind CSS in SvelteKit Project
npm install -D tailwindcss postcss autoprefixer svelte-preprocess
This will install TailwindCSS, PostCSS, AutoPrefixer and Svelte Preprocess. For more about them please google.
npx tailwindcss init tailwind.config.cjs -p
import preprocess from 'svelte-preprocess';
preprocess: [
preprocess({
postcss: true
})
],
content: ['./src/**/*.{html,js,svelte,ts}'],
src
named app.css
(just naming convention) and add this following lines in the app.css
:
@tailwind base;
@tailwind components;
@tailwind utilities;
src/routes
named __layout.svelte
(Not a naming convention) and add following lines of code in layout.svelte
:
<script>
import "../app.css";
</script>
<slot />
src/routes/index.svelte
file:
<h1 class="text-3xl font-bold underline">
Hello world!
</h1>
On dev serve you will find it. For more, how tailwind classes work => use tailwind docs.
This is me writing for you. If you wanna ask or suggest anything please put it in comment.
Our service will help you design and develop your product.