<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arpit Jalan</title>
    <description>The latest articles on DEV Community by Arpit Jalan (@arpitjalan).</description>
    <link>https://dev.to/arpitjalan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1036873%2Fbed38a33-bfaa-46be-9da0-5b687d47ebe6.jpeg</url>
      <title>DEV Community: Arpit Jalan</title>
      <link>https://dev.to/arpitjalan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arpitjalan"/>
    <language>en</language>
    <item>
      <title>How to setup SvelteKit with Tailwind CSS</title>
      <dc:creator>Arpit Jalan</dc:creator>
      <pubDate>Thu, 02 Mar 2023 08:13:21 +0000</pubDate>
      <link>https://dev.to/arpitjalan/how-to-setup-sveltekit-with-tailwind-css-49go</link>
      <guid>https://dev.to/arpitjalan/how-to-setup-sveltekit-with-tailwind-css-49go</guid>
      <description>&lt;h2&gt;
  
  
  What is SvelteKit?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://kit.svelte.dev"&gt;SvelteKit&lt;/a&gt;, built on top of Svelte, is a framework for rapidly developing robust, performant web applications. You can read more about Svelte &lt;a href="https://dev.to/arpitjalan/introduction-to-svelte-3i4k"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Tailwind CSS?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com"&gt;Tailwind CSS&lt;/a&gt; is 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup SvelteKit with Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;First, let's create a new SvelteKit project if you don't have one set up already.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create svelte@latest myapp
&lt;span class="nb"&gt;cd &lt;/span&gt;myapp
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the Tailwind CSS dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; tailwindcss postcss autoprefixer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the Tailwind CSS config files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tailwindcss init tailwind.config.cjs &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your &lt;code&gt;svelte.config.js&lt;/code&gt; file, import &lt;code&gt;vitePreprocess&lt;/code&gt; to enable processing &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; blocks as PostCSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// svelte.config.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;adapter&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@sveltejs/adapter-auto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;vitePreprocess&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@sveltejs/kit/vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('@sveltejs/kit').Config} */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.&lt;/span&gt;
        &lt;span class="c1"&gt;// If your environment is not supported or you settled on a specific environment, switch out the adapter.&lt;/span&gt;
        &lt;span class="c1"&gt;// See https://kit.svelte.dev/docs/adapters for more information about adapters.&lt;/span&gt;
        &lt;span class="na"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;preprocess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;vitePreprocess&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the paths to all of your template files in your &lt;code&gt;tailwind.config.cjs&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//tailwind.config.cjs&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} */&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/**/*.{html,js,svelte,ts}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a &lt;code&gt;./src/app.css&lt;/code&gt; file and add the &lt;code&gt;@tailwind&lt;/code&gt; directives for each of Tailwind’s layers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app.css */&lt;/span&gt;

&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a &lt;code&gt;./src/routes/+layout.svelte&lt;/code&gt; file and import the newly-created &lt;code&gt;app.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight svelte"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- +layout.svelte --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../app.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;slot&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! You can now start using Tailwind CSS utility classes in your markup! 🚀&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight svelte"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- +page.svelte --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-3xl font-bold underline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Welcome to SvelteKit&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The combination of SvelteKit &amp;amp; Tailwind CSS provides a powerful toolset for creating modern web applications that are both visually appealing and highly functional. Whether you're building a small personal project or a large-scale enterprise application, the SvelteKit &amp;amp; Tailwind integration is a great choice for optimizing your design and development workflow.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href="https://github.com/arpitjalan/sveltekit-tailwind"&gt;repository at GitHub&lt;/a&gt; to see the source code.&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>svelte</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Introduction to Svelte</title>
      <dc:creator>Arpit Jalan</dc:creator>
      <pubDate>Thu, 02 Mar 2023 08:09:39 +0000</pubDate>
      <link>https://dev.to/arpitjalan/introduction-to-svelte-3i4k</link>
      <guid>https://dev.to/arpitjalan/introduction-to-svelte-3i4k</guid>
      <description>&lt;h2&gt;
  
  
  What is Svelte?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt; is a modern JavaScript framework for building user interfaces that are designed to be fast, efficient, and easy to use. With Svelte, developers can create complex and interactive web applications quickly and easily.&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes Svelte different?
&lt;/h2&gt;

&lt;p&gt;It has a unique approach to building web applications. Whereas traditional frameworks like React and Ember do the bulk of their work in the &lt;em&gt;browser&lt;/em&gt;, Svelte shifts that work into a &lt;em&gt;compile step&lt;/em&gt; that happens when you build your app.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The edge Svelte has over other frameworks is that Svelte is a compiler, and therefore it doesn’t use virtual DOM.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The outcome of this approach is not only smaller application bundles and better performance, but also a developer experience that is more approachable for people that have limited experience with the modern tooling ecosystem.&lt;/p&gt;

&lt;p&gt;Svelte sticks closely to the classic web development model of HTML, CSS, and JS, just adding a few extensions to HTML and JavaScript. It arguably has fewer concepts and tools to learn than some of the other framework options.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does Svelte work?
&lt;/h2&gt;

&lt;p&gt;Svelte, being a compiler, has the ability to extend HTML, CSS, and JavaScript by producing efficient JavaScript code without any runtime overhead. To accomplish this, Svelte expands upon vanilla web technologies in the following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It extends HTML by enabling JavaScript expressions in markup and introducing directives that enable the use of conditions and loops, similar to &lt;a href="https://handlebarsjs.com"&gt;handlebars&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;It extends CSS by implementing a scoping mechanism that enables each component to define its own styles without the potential for conflicts with styles from other components.&lt;/li&gt;
&lt;li&gt;It broadens the capabilities of JavaScript by reinterpreting certain directives within the language, resulting in true reactivity and streamlined component state management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Svelte compiler only intervenes in highly particular circumstances and solely within the scope of Svelte components. Changes made to the JavaScript language are kept to a minimum and chosen with great care so as not to disrupt JavaScript syntax or estrange developers. You will primarily be utilizing plain JavaScript (or optionally, TypeScript).&lt;/p&gt;

&lt;p&gt;To try Svelte in an interactive online environment you can try the &lt;a href="https://svelte.dev/repl/hello-world"&gt;REPL&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating your first Svelte app
&lt;/h3&gt;

&lt;p&gt;To create a project locally the recommended way is to use &lt;a href="https://kit.svelte.dev"&gt;SvelteKit&lt;/a&gt;, the official application framework from the Svelte team:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create svelte@latest myapp
&lt;span class="nb"&gt;cd &lt;/span&gt;myapp
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SvelteKit will handle calling the Svelte compiler to convert your &lt;code&gt;.svelte&lt;/code&gt; files into &lt;code&gt;.js&lt;/code&gt; files that create the DOM and &lt;code&gt;.css&lt;/code&gt; files that style it. It also provides all the other pieces you need to build a web application such as a development server, routing, and deployment.&lt;/p&gt;

&lt;p&gt;A typical SvelteKit project looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myapp/
├ src/
│ ├ lib/
│ │ ├ server/
│ │ │ └ [your server-only lib files]
│ │ └ [your lib files]
│ ├ params/
│ │ └ [your param matchers]
│ ├ routes/
│ │ └ [your routes]
│ ├ app.html
│ ├ error.html
│ ├ hooks.client.js
│ └ hooks.server.js
├ static/
│ └ [your static assets]
├ tests/
│ └ [your tests]
├ package.json
├ svelte.config.js
├ tsconfig.json
└ vite.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read more about SvelteKit project structure &lt;a href="https://kit.svelte.dev/docs/project-structure"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After running &lt;code&gt;npm run dev&lt;/code&gt;, Svelte will compile and build your application. SvelteKit will start a local server at &lt;code&gt;localhost:5173&lt;/code&gt;. It will watch for file updates and automatically recompile and refresh the app for you when changes are made to the source files.&lt;/p&gt;

&lt;p&gt;Go ahead and play with the files generated in the &lt;code&gt;myapp&lt;/code&gt; folder and see the changes live on your &lt;a href="https://dev.tolocalhost:5173"&gt;local server&lt;/a&gt;. If you face any difficulty or want to learn more the &lt;a href="https://kit.svelte.dev/docs/introduction"&gt;official docs&lt;/a&gt; are your friend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Svelte stands out as an incredibly intuitive framework that I have grown to love more and more with each use. For beginners, I highly recommend Svelte as your first choice because of its focus on adhering to &lt;a href="https://kit.svelte.dev/docs/web-standards"&gt;web standards&lt;/a&gt;. As a seasoned web developer, you will likely appreciate the simplicity of Svelte and perhaps even rediscover your passion for web development.&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
