<?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: prem1835</title>
    <description>The latest articles on DEV Community by prem1835 (@prem1835).</description>
    <link>https://dev.to/prem1835</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%2F235636%2F533da146-b2b4-4267-b9fe-edbaedd4fa44.jpg</url>
      <title>DEV Community: prem1835</title>
      <link>https://dev.to/prem1835</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prem1835"/>
    <language>en</language>
    <item>
      <title>Moving Particles Background In ReactJS</title>
      <dc:creator>prem1835</dc:creator>
      <pubDate>Sun, 26 Jul 2020 11:06:28 +0000</pubDate>
      <link>https://dev.to/prem1835/moving-particles-background-in-reactjs-f3l</link>
      <guid>https://dev.to/prem1835/moving-particles-background-in-reactjs-f3l</guid>
      <description>&lt;p&gt;So you're a beginner in web development like me. And many times when you visit some websites that have amazing moving backgrounds, you become curious to know, how they implement it. &lt;br&gt;
Else like me "they must be genius" :)&lt;/p&gt;

&lt;p&gt;So today I'm going to show you the process of how to implements Moving Particles Background in your own website or how to create an eye-catching portfolio website using TypeScript library called &lt;a href="https://github.com/matteobruni/tsparticles" rel="noopener noreferrer"&gt;&lt;strong&gt;tsParticles&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1uyvw3bbb9l700748mt0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1uyvw3bbb9l700748mt0.png" alt="Moving particles"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to install tsParticles component
&lt;/h2&gt;

&lt;p&gt;Open your terminal and go to location of your ReactJS project. And type following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-tsparticles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react-tsparticles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will install a ReactJS component in your project.&lt;/p&gt;

&lt;p&gt;If you're starting with a brand-new project than you can simply type this command and it will install this component with the create-react-app. Put name of your project in the place of "your_app"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create-react-app your_app --template particles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to use
&lt;/h2&gt;

&lt;p&gt;Now you have to import it in your component where you want to implement it. You can also make a separate component for tsparticles and import it on top 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;import Particles from "react-tsparticles";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After importing it in your component, you can use the &amp;lt;&lt;strong&gt;Particles&lt;/strong&gt; /&amp;gt; in your code.&lt;/p&gt;

&lt;p&gt;Now You have to pass props to this component to make this background effect work and you can also change and play around with properties to experiments with different effects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Particles
        id="tsparticles"
        options={{
          background: {
            color: {
              value: "#0d47a1",
            },
          },
          fpsLimit: 60,
          interactivity: {
            detectsOn: "canvas",
            events: {
              onClick: {
                enable: true,
                mode: "push",
              },
              onHover: {
                enable: true,
                mode: "repulse",
              },
              resize: true,
            },
            modes: {
              bubble: {
                distance: 400,
                duration: 2,
                opacity: 0.8,
                size: 40,
              },
              push: {
                quantity: 4,
              },
              repulse: {
                distance: 200,
                duration: 0.4,
              },
            },
          },
          particles: {
            color: {
              value: "#ffffff",
            },
            links: {
              color: "#ffffff",
              distance: 150,
              enable: true,
              opacity: 0.5,
              width: 1,
            },
            collisions: {
              enable: true,
            },
            move: {
              direction: "none",
              enable: true,
              outMode: "bounce",
              random: false,
              speed: 6,
              straight: false,
            },
            number: {
              density: {
                enable: true,
                value_area: 800,
              },
              value: 80,
            },
            opacity: {
              value: 0.5,
            },
            shape: {
              type: "circle",
            },
            size: {
              random: true,
              value: 5,
            },
          },
          detectRetina: true,
        }}
      /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have to render &amp;lt;&lt;strong&gt;Particles&lt;/strong&gt; /&amp;gt; component and you will see magical effects. I'm sure, it will bring smile on your face :)&lt;/p&gt;

&lt;p&gt;You can check this Official &lt;a href="https://github.com/matteobruni/tsparticles/blob/master/components/react/README.md#code" rel="noopener noreferrer"&gt;&lt;strong&gt;tsParticles&lt;/strong&gt;&lt;/a&gt; ReactJS GitHub repository for more details explanation&lt;/p&gt;

&lt;p&gt;Thank you for reading this post, I hope it helps you.&lt;/p&gt;

&lt;p&gt;This is my first ever post so feedbacks and suggestions are welcome!&lt;/p&gt;

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