<?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: Dakota Day</title>
    <description>The latest articles on DEV Community by Dakota Day (@dakota_day).</description>
    <link>https://dev.to/dakota_day</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%2F1429377%2F60a1ac76-3462-4615-a2a2-1e6c9a83cc5d.jpeg</url>
      <title>DEV Community: Dakota Day</title>
      <link>https://dev.to/dakota_day</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dakota_day"/>
    <language>en</language>
    <item>
      <title>Checking Out Chakra UI</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 14 Oct 2024 02:21:47 +0000</pubDate>
      <link>https://dev.to/dakota_day/checking-out-chakra-ui-jfj</link>
      <guid>https://dev.to/dakota_day/checking-out-chakra-ui-jfj</guid>
      <description>&lt;p&gt;Welcome to my third and final blog in my styling mini-series. Today I'll be going over the youngest library I've worked with, initially released in 2022, Chakra UI. For this showcase, I'll be using Chakra v2.10.1 with React v18.3.1 in Node v22.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Choose Chakra?
&lt;/h2&gt;

&lt;p&gt;You may be wondering, "What's Chakra's selling points?". Well despite being a very young library, Chakra has exploded in popularity. This means you'll have comparable support to some bigger, more established libraries like Material UI. Arguably my favorite aspects of Chakra would be its built in dark and light mode support and how accessible it is out the box. And lastly, Chakra UI has a keen focus on keeping its components customizable to fit your specific needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Chakra is easy to set up and get running. You'll first grab the necessary packages: with npm - &lt;code&gt;npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion&lt;/code&gt; or with yarn - &lt;code&gt;yarn add @chakra-ui/react @emotion/react @emotion/styled framer-motion&lt;/code&gt;. After installing, you have to set up the &lt;em&gt;ChakraProvider&lt;/em&gt; at the root of your application, which will look like this a majority of the time:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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;react&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="nx"&gt;ReactDOM&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;react-dom/client&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;ChakraProvider&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;@chakra-ui/react&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="nx"&gt;App&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;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ChakraProvider&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ChakraProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Themes and Customization
&lt;/h2&gt;

&lt;p&gt;Themes allow developers to define a set of design standards that can be applied consistently across an application. Chakra UI comes with built-in theming capabilities that let devs customize the look and feel of their projects.&lt;br&gt;
Applying these themes are as simple as slightly modifying our example from above to include a custom theme:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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;react&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="nx"&gt;ReactDOM&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;react-dom/client&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;ChakraProvider&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;@chakra-ui/react&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="nx"&gt;customTheme&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;./Theme&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="nx"&gt;App&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;./App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ChakraProvider&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;customTheme&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ChakraProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a separate file, in this case Theme, you can set your own theming rules to override Chakra's defaults, and then you just pass it as a prop to the ChakraProvider.&lt;/p&gt;

&lt;h3&gt;
  
  
  Colors
&lt;/h3&gt;

&lt;p&gt;Chakra uses a unique approach to colors, in the form of palettes. This means that their default colors have ranges, from 50 - 900, where the higher you go, the darker shades you have. Their default theme was inspired by Tailwind CSS. Be sure to check out the color spreads in the &lt;a href="https://v2.chakra-ui.com/docs/styled-system/theme#colors" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Typography
&lt;/h3&gt;

&lt;p&gt;Your theme allows customization for font styles, sizes, and weights to maintain a consistent typography throughout your app. You can also customize headings, and more general body text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Spacing
&lt;/h3&gt;

&lt;p&gt;Chakra UI enables you to control the spacing between elements. Margins, paddings, and gaps can all be configured within the theme. &lt;/p&gt;

&lt;h3&gt;
  
  
  Breakpoints
&lt;/h3&gt;

&lt;p&gt;Breakpoints in Chakra allow developers to build responsive designs that look good on any screen size. You can define your own via theming, or use the default Chakra values to create a responsive grid system.&lt;/p&gt;

&lt;p&gt;Throwing these together you can have a simple theme that may look like this:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;extendTheme&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;@chakra-ui/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Define a custom color palette&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ffe5f7&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ffb3e0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ff80c9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ff4db1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ff1a99&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#e60080&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#b30066&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#80004d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#4d0033&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#1a001a&lt;/span&gt;&lt;span class="dl"&gt;'&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="c1"&gt;// Define custom typography settings&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;typography&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`'Poppins', sans-serif`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Custom font for headings&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`'Roboto', sans-serif`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Custom font for body text&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;fontSizes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;sm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;12px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;md&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;16px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;20px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;24px&lt;/span&gt;&lt;span class="dl"&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;fontWeights&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;700&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="c1"&gt;// Define spacing scale&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;space&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;px&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;4px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;8px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;12px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;16px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;20px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;24px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;32px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;40px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;48px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;64px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;80px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;96px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Extend the default Chakra theme&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;customTheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;extendTheme&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;typography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;fontSizes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;typography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fontSizes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;fontWeights&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;typography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fontWeights&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;space&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;customTheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Light/Dark Mode
&lt;/h3&gt;

&lt;p&gt;Light and dark mode has never been easier! Chakra has built in functionality for light and dark mode toggles through their &lt;em&gt;useColorMode&lt;/em&gt; and &lt;em&gt;useColorModeValue&lt;/em&gt; React hooks.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useColorMode&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;@chakra-ui/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;colorMode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggleColorMode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useColorMode&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toggleColorMode&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;Toggle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;colorMode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&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;Dark&lt;/span&gt;&lt;span class="dl"&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;Light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/header&lt;/span&gt;&lt;span class="err"&gt;&amp;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;And just like that, you have a fully functional button to toggle between light and dark mode!&lt;br&gt;
But what if you need to adjust some colors between light and dark mode? Chakra allows this by using &lt;em&gt;useColorModeValue&lt;/em&gt;. Its signature looks like this &lt;code&gt;const value = useColorModeValue(lightModeValue, darkModeValue)&lt;/code&gt;.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useColorMode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useColorModeValue&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;@chakra-ui/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;StyleColorMode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;toggleColorMode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useColorMode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useColorModeValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red.500&lt;/span&gt;&lt;span class="dl"&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;red.200&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useColorModeValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;white&lt;/span&gt;&lt;span class="dl"&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;gray.800&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Box&lt;/span&gt; &lt;span class="nx"&gt;mb&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;s style will change based on the color mode.
      &amp;lt;/Box&amp;gt;
      &amp;lt;Button size=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="nx"&gt;sm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; onClick={toggleColorMode}&amp;gt;
        Toggle Mode
      &amp;lt;/Button&amp;gt;
    &amp;lt;/&amp;gt;
  )
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the background of the box will be a darker shade of red in light mode and a lighter shade in dark mode, while the text will be white, and dark gray respectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessibility
&lt;/h2&gt;

&lt;p&gt;Chakra UI has accessibility baked into its core, ensuring that your UI components are not just visually appealing but also usable by everyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Buttons
&lt;/h3&gt;

&lt;p&gt;Buttons play a vital role in interactivity, and Chakra UI provides several features to ensure they are accessible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Contrast&lt;/strong&gt;: Chakra's default button colors are designed to meet accessibility standards for contrast ratios. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Focus States&lt;/strong&gt;: Automatically include focus styles. This means when a user navigates using a keyboard (via the Tab key), the button receives a visible focus outline, ensuring that it’s clear which element is in focus.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ARIA Attributes&lt;/strong&gt;: Buttons in Chakra UI are implemented with proper ARIA (Accessible Rich Internet Applications) roles. For instance, if a button has a custom behavior, you can easily add aria-label attributes to enhance screen reader accessibility.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Forms
&lt;/h3&gt;

&lt;p&gt;Forms are crucial for user input, and Chakra UI makes them accessible by default.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Proper Labeling&lt;/strong&gt;: Form controls like inputs, checkboxes, and radio buttons are designed to be accessible with automatic association between labels and form elements. Chakra's &lt;code&gt;&amp;lt;FormLabel&amp;gt;&lt;/code&gt; component ensures that labels are correctly bound to the form controls, making it easier for screen readers to interpret them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Validation States&lt;/strong&gt;: Ensure that error messages are appropriately connected to the form controls using aria-invalid and other ARIA attributes.&lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;FormControl&lt;/span&gt; &lt;span class="na"&gt;isRequired&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;FormLabel&lt;/span&gt; &lt;span class="na"&gt;htmlFor=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email Address&lt;span class="nt"&gt;&amp;lt;/FormLabel&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;FormHelperText&amp;gt;&lt;/span&gt;We'll never share your email.&lt;span class="nt"&gt;&amp;lt;/FormHelperText&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/FormControl&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the &lt;code&gt;htmlFor&lt;/code&gt; attribute binds the label to the input element, and the helper text offers guidance, all accessible by screen readers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modals
&lt;/h3&gt;

&lt;p&gt;Chakra's modals are designed with accessibility in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Focus Trapping&lt;/strong&gt;: When a modal opens, focus trapping ensures that users can't tab out of the modal content unintentionally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keyboard Navigation&lt;/strong&gt;: Modals are fully navigable with a keyboard. Pressing the Tab key moves focus through interactive elements (like buttons or links) within the modal. The Esc key can be used to close the modal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Aria Labels and Roles&lt;/strong&gt;: Modals come with built-in ARIA roles such as &lt;code&gt;aria-modal&lt;/code&gt; to define the dialog role. You can also add &lt;code&gt;aria-labelledby&lt;/code&gt; and &lt;code&gt;aria-describedby&lt;/code&gt; attributes to describe the modal content to assistive technologies.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;All in all, Chakra is a very fun and accessible component library to work with. With things like built in light/dark mode support and a very large lean into accessibility, Chakra can be described as THE modern component library, despite being so young. I would implore you to try out Chakra and see if you like it!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Bootstrap Basics</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 30 Sep 2024 01:16:41 +0000</pubDate>
      <link>https://dev.to/dakota_day/bootstrap-basics-33dp</link>
      <guid>https://dev.to/dakota_day/bootstrap-basics-33dp</guid>
      <description>&lt;p&gt;Welcome to the second part of my styling series where I go over some popular styling libraries/frameworks. In this blog, we'll go over Bootstrap. Bootstrap is a powerful, open source frontend framework that makes building websites faster and easier by providing an intuitive grid system, UI components, and an extensive array of utility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Of course before getting into some of the features, we have to talk about setting up Bootstrap in a project. &lt;em&gt;At the time of writing, Bootstrap's current version is 5.3.3 and that is what I'll be using for any examples.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bootstrap Via CDN
&lt;/h3&gt;

&lt;p&gt;Bootstrap can be set up very quickly by using a CDN, or content delivery network. This method does not require any installation, just add Bootstrap's CSS and JavaScript links to your HTML file and you're off to the races!&lt;br&gt;
You'll put the following CSS link inside the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag of your HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;integrity=&lt;/span&gt;&lt;span class="s"&gt;"sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"&lt;/span&gt; &lt;span class="na"&gt;crossorigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&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;After that, you'll put the following script before the closing &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"&lt;/span&gt; &lt;span class="na"&gt;integrity=&lt;/span&gt;&lt;span class="s"&gt;"sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"&lt;/span&gt; &lt;span class="na"&gt;crossorigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Via Package Manager
&lt;/h3&gt;

&lt;p&gt;If you're working in a larger project, or working with modern frontend tools, you may want to install via project manager. Lucky for us, this is simple as well! In your terminal, just write &lt;code&gt;npm install bootstrap&lt;/code&gt; if using npm, or &lt;code&gt;yarn add bootstrap&lt;/code&gt; if using yarn. After installing you'll want to import bootstrap's CSS and JavaScript into your main CSS and JS files respectfully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Import Bootstrap CSS
import 'bootstrap/dist/css/bootstrap.min.css';

// Import Bootstrap JavaScript
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Grid System
&lt;/h2&gt;

&lt;p&gt;One of Bootstrap's most powerful features is its grid system. This allows you to create responsive layouts that automatically adjust to different screen sizes. &lt;/p&gt;

&lt;h3&gt;
  
  
  Structure
&lt;/h3&gt;

&lt;p&gt;The grid is based on a 12-column structure to organize content. Its basic structure can look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Column 1&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Column 2&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Column 3&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Container: The container holds the columns and rows while aligning them&lt;/li&gt;
&lt;li&gt;Row: The rows hold and group columns together horizontally&lt;/li&gt;
&lt;li&gt;Col: The columns are where your content will live, each row can have 12 &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Sizes
&lt;/h4&gt;

&lt;p&gt;Columns can also have their own sizes! This can be used to provide different layouts. They are notated by how many columns they'll take up on the row.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-12"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;100% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;50% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;50% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;33.33% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;33.33% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;33.33% Width&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Breakpoints
&lt;/h4&gt;

&lt;p&gt;Bootstraps grid is mobile first, meaning it's built for mobile devices before scaling up to larger devices. Because of this, Bootstrap has classes that define how columns act across different screen sizes. These are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;xs: For screens less than 576px&lt;/li&gt;
&lt;li&gt;sm: For screens more than 576px&lt;/li&gt;
&lt;li&gt;md: For screens more than 768px&lt;/li&gt;
&lt;li&gt;lg: For screens more than 992px&lt;/li&gt;
&lt;li&gt;xl: For screens more than 1200px&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"row"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-12 col-md-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Wide on medium and larger screens&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"col-6 col-md-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Narrower on medium and larger screens&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the first column takes up the full width on small screens, but only eight grid units on medium or larger screens. The second will take up half the width on small screens, and only four units on medium or larger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Components
&lt;/h2&gt;

&lt;p&gt;Bootstrap gives us a variety of pre-built components that help in creating appealing, user friendly websites with minimal custom CSS. There are a lot of components, so I'll go over some of the more common one's you're likely to work with.&lt;/p&gt;

&lt;h3&gt;
  
  
  Typography
&lt;/h3&gt;

&lt;p&gt;We'll start by talking about text, since your users need to read to believe. The typography classes make defining consistent text styles easy, from headings, to body text, to lists. For example, the different heading are notated by their display class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&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;"display-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Heading 1&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"display-2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Heading 2&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h3&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"display-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Heading 3&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"lead"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is lead text, which stands out from regular paragraph text.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is regular paragraph text.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"small"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is small text, which stands out from regular paragraph text.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also define paragraph text with utility classes to modify body text as seen above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Buttons
&lt;/h3&gt;

&lt;p&gt;Every website or app needs buttons! Bootstrap gives a variety of button styles out the box. Their classes are defined as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Basic Buttons --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Primary Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-secondary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Secondary Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-danger"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Danger Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Button Sizes --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary btn-lg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Large Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-primary btn-sm"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Small Button&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Button Outlines--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-outline-success"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Success Outline&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn btn-outline-warning"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Warning Outline&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  NavBar
&lt;/h3&gt;

&lt;p&gt;Bootstrap's navbar component comes with built in classes for alignment, dropdowns, and more!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;nav&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar navbar-expand-lg navbar-light bg-light"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-brand"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Navbar&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-toggler"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"button"&lt;/span&gt; &lt;span class="na"&gt;data-toggle=&lt;/span&gt;&lt;span class="s"&gt;"collapse"&lt;/span&gt; &lt;span class="na"&gt;data-target=&lt;/span&gt;&lt;span class="s"&gt;"#navbarNav"&lt;/span&gt; &lt;span class="na"&gt;aria-controls=&lt;/span&gt;&lt;span class="s"&gt;"navbarNav"&lt;/span&gt; &lt;span class="na"&gt;aria-expanded=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="na"&gt;aria-label=&lt;/span&gt;&lt;span class="s"&gt;"Toggle navigation"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-toggler-icon"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"collapse navbar-collapse"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"navbarNav"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"navbar-nav"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-item active"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Home&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Features&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Pricing&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the navbar will collapse on smaller screens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Utility Classes
&lt;/h2&gt;

&lt;p&gt;Bootstrap also includes a wide range of utility classes to help speed along development and reduce the need for custom CSS. With just a few class names, you can adjust spacing, alignment, display properties and more!&lt;/p&gt;

&lt;h3&gt;
  
  
  Spacing
&lt;/h3&gt;

&lt;p&gt;Spacing is extremely important in development for user readability. Thankfully, Bootstrap gives us classes to adjust margins and padding of elements. They all follow a similar format of &lt;code&gt;{property}{sides}-{size}&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Property: &lt;code&gt;m&lt;/code&gt; for margin, &lt;code&gt;p&lt;/code&gt; for padding&lt;/li&gt;
&lt;li&gt;Sides: &lt;code&gt;t&lt;/code&gt; top, &lt;code&gt;b&lt;/code&gt; bottom, &lt;code&gt;s&lt;/code&gt; start(left), &lt;code&gt;e&lt;/code&gt; end(right), &lt;code&gt;x&lt;/code&gt; left and right, &lt;code&gt;y&lt;/code&gt; top and bottom, or blank for all sides&lt;/li&gt;
&lt;li&gt;Size: &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, ..., or &lt;code&gt;auto&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Margin Top of 3&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"p-5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Padding of 5&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mx-auto"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"width: 300px"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Horizontally Centered with Auto Margin&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display
&lt;/h3&gt;

&lt;p&gt;Display utilities help control the visibility and layout of elements. These can be used to show, hide, or change how elements behave. The display classes include: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;d-block&lt;/code&gt;: Display as a block element&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d-inline&lt;/code&gt;: Display as an inline element&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d-none&lt;/code&gt;: Hide the element&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d-flex&lt;/code&gt;: Enable Flexbox&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d-inline-block&lt;/code&gt;: Display as an inline block&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bootstrap also provides responsive versions of these classes that apply to breakpoints, such as &lt;code&gt;d-none d-md-block&lt;/code&gt;, this hides an element on small screens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"d-none d-md-block"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Visible on medium and larger screens&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"d-flex justify-content-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Centered with Flexbox&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Text Utilities
&lt;/h3&gt;

&lt;p&gt;Bootstrap gives a large amount of text customization with classes like:&lt;/p&gt;

&lt;h4&gt;
  
  
  Text Alignment
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;text-start&lt;/code&gt;: Aligns text to the left&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-end&lt;/code&gt;: Aligns text to the right&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-center&lt;/code&gt;: Aligns text to the center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Text Wrapping
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;text-nowrap&lt;/code&gt;: Prevent text from wrapping to the next line&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-truncate&lt;/code&gt;: Truncate text with an ellipsis if it's too long&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Text Color
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;text-primary&lt;/code&gt;: Text with primary color (default: blue)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-success&lt;/code&gt;: Text with success color (default: green)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-danger&lt;/code&gt;: Text with danger color (default: red)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-center text-success"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This text is centered and green&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-end text-primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This text is right-aligned and blue&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;Bootstrap is a powerful and flexible framework that allows devs to build responsive websites efficiently. By mastering these foundational concepts, you'll be able to streamline your workflow and focus more on the design and functionality of your site rather than with custom CSS and layout management. So dive in! Experiment with some of the examples and build an amazing app!&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Mastering Material UI</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 16 Sep 2024 05:14:29 +0000</pubDate>
      <link>https://dev.to/dakota_day/mastering-material-ui-3hj0</link>
      <guid>https://dev.to/dakota_day/mastering-material-ui-3hj0</guid>
      <description>&lt;p&gt;This is the first part of a mini series where I'll be covering some common frontend styling libraries, starting with Material UI. Material UI (MUI) is a React component library that implements Google's Material Design. When opening up the MUI docs, it can be a little intimidating because of just how many components there are. This blog will be running through a fair chunk of MUI components with the goal of learning what they do, and how they can help with frontend productivity.&lt;/p&gt;

&lt;p&gt;To start, I'll be using MUI's &lt;a href="https://github.com/mui/material-ui/blob/v4.x/docs/src/pages/getting-started/templates/album/Album.js" rel="noopener noreferrer"&gt;Album Template&lt;/a&gt; for demo purposes, as I feel that it uses some of the more common components that you'll likely be using. Please note that this repo is older, so some of the components in it are deprecated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;MUI is pretty much plug and play. It does have two peer dependencies, react and react-dom, so ensure that these are installed first. After those are installed, if using npm, run this command: &lt;code&gt;npm install @mui/material @emotion/react @emotion/styled&lt;/code&gt;. This will install the latest version of MUI, at the time of writing, I used v6.1.0 with React v18.3.1. If you want to use MUI's icon library, you can use this command: &lt;code&gt;npm install @mui/icons-material&lt;/code&gt;. Be sure to checkout &lt;a href="https://mui.com/material-ui/material-icons/" rel="noopener noreferrer"&gt;MUI Icons library&lt;/a&gt;. Any components you want to use can be imported directly into the file where you want to use it. The import format is &lt;code&gt;import { Component } from '@mui/material/Component';&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Template
&lt;/h3&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%2Fuploads%2Farticles%2Fepidd0c1zsu3ojsupvrl.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%2Fuploads%2Farticles%2Fepidd0c1zsu3ojsupvrl.png" alt="Album Demo"&gt;&lt;/a&gt; After making a few changes to the default repo this is what the album template looks like. Let's start picking apart some of the components used.&lt;/p&gt;

&lt;h3&gt;
  
  
  MUI Components
&lt;/h3&gt;

&lt;h5&gt;
  
  
  CssBaseline
&lt;/h5&gt;

&lt;p&gt;We'll start with CssBaseline, this component can be boiled down to a collection of HTML element and attribute style normalizations based on normalize.js. This basically ensures that all of your elements will look the same across browsers.&lt;/p&gt;

&lt;h5&gt;
  
  
  AppBar/ToolBar
&lt;/h5&gt;

&lt;p&gt;The AppBar and ToolBar work in tandem to build a functional navigation bar right out the box. The ToolBar acts as a layout helper within the AppBar component.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;AppBar&lt;/span&gt; &lt;span class="na"&gt;position=&lt;/span&gt;&lt;span class="s"&gt;"relative"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Toolbar&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;CameraIcon&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Typography&lt;/span&gt; &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"h6"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"inherit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      Album layout
    &lt;span class="nt"&gt;&amp;lt;/Typography&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/Toolbar&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/AppBar&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;AppBar has a position prop that we can use to determine how the nav bar reacts when scrolling on a page. This example is really simple but you could position buttons, dropdown menus, and more within these components.&lt;/p&gt;

&lt;h5&gt;
  
  
  Container
&lt;/h5&gt;

&lt;p&gt;The container component is what will hold your other components for a page. They have a &lt;code&gt;maxWidth&lt;/code&gt; prop that allows the container to grow with the size of the screen.&lt;/p&gt;

&lt;h5&gt;
  
  
  Grid2
&lt;/h5&gt;

&lt;p&gt;Grid2 is MUI's version 2 of the Grid component. It's used for creating flexible layouts within containers. It follows the CSS Flexbox model and uses the 12 column grid system. The grid work in a two part system, where one grid acts as the &lt;code&gt;container&lt;/code&gt; and the child one acts as the &lt;code&gt;item&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;Grid2&lt;/span&gt; &lt;span class="na"&gt;container&lt;/span&gt; &lt;span class="na"&gt;spacing=&lt;/span&gt;&lt;span class="s"&gt;{2}&lt;/span&gt; &lt;span class="na"&gt;justifyContent=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Grid2&lt;/span&gt; &lt;span class="na"&gt;item&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt; &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"contained"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      Main call to action
    &lt;span class="nt"&gt;&amp;lt;/Button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/Grid2&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Grid2&lt;/span&gt; &lt;span class="na"&gt;item&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt; &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"outlined"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      Secondary action
    &lt;span class="nt"&gt;&amp;lt;/Button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/Grid2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Grid2&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h5&gt;
  
  
  Button
&lt;/h5&gt;

&lt;p&gt;We'll also use this example to talk about the Button component as well. Every app needs buttons right? MUI comes with pre-built button components that are styled out the box. They have a variant prop to define the button's style. You have three variants to choose from: text, contained, and outlined. Not to mention you get access to the color prop which has a few pre-made ones like primary, secondary, success, and error.&lt;/p&gt;
&lt;h5&gt;
  
  
  Typography
&lt;/h5&gt;

&lt;p&gt;The typography component is your building block for any text you may use in your app. This means titles, paragraphs, labels, etc. This component ensures that text follows best practices for accessibility and consistency.&lt;/p&gt;
&lt;h6&gt;
  
  
  Features
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Scales font sizes based on screen size.&lt;/li&gt;
&lt;li&gt;Variant prop for changing text to heading, body, and more 
Let's look at the header and paragraph under it for an example&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;Typography&lt;/span&gt;
  &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"h2"&lt;/span&gt;
  &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
  &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"textPrimary"&lt;/span&gt;
  &lt;span class="na"&gt;gutterBottom&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Album layout
&lt;span class="nt"&gt;&amp;lt;/Typography&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Typography&lt;/span&gt;
  &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"h5"&lt;/span&gt;
  &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
  &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"textSecondary"&lt;/span&gt;
  &lt;span class="na"&gt;gutterBottom&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks don't simply skip over it entirely.
&lt;span class="nt"&gt;&amp;lt;/Typography&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here we can see some of the different props coming into play: &lt;code&gt;variant&lt;/code&gt; changing the text types, &lt;code&gt;align&lt;/code&gt; tells the text where to align, &lt;code&gt;color&lt;/code&gt; sets the color of the text, and &lt;code&gt;gutterBottom&lt;/code&gt; sets a small margin under the text. In the second typography, we can also see that by default, longer strings of text auto-wrap where they are aligned.&lt;/p&gt;

&lt;h5&gt;
  
  
  Card
&lt;/h5&gt;

&lt;p&gt;Finally let's go over cards. Cards are another container for displaying organized content. It is highly customizable and has subcomponents like CardHeader, CardMedia, CardContent, and CardActions.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="nt"&gt;&amp;lt;Card&amp;gt;&lt;/span&gt;&lt;br&gt;
  &lt;span class="nt"&gt;&amp;lt;CardContent&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;Typography&lt;/span&gt; &lt;span class="na"&gt;gutterBottom&lt;/span&gt; &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"h5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      Heading&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;/Typography&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;Typography&amp;gt;&lt;/span&gt;&lt;br&gt;
      This is a media card. You can use this section to describe the content.&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;/Typography&amp;gt;&lt;/span&gt;&lt;br&gt;
  &lt;span class="nt"&gt;&amp;lt;/CardContent&amp;gt;&lt;/span&gt;&lt;br&gt;
  &lt;span class="nt"&gt;&amp;lt;CardActions&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt; &lt;span class="na"&gt;size=&lt;/span&gt;&lt;span class="s"&gt;"small"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      View&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;/Button&amp;gt;&lt;/span&gt;&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt; &lt;span class="na"&gt;size=&lt;/span&gt;&lt;span class="s"&gt;"small"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
      Edit&lt;br&gt;
    &lt;span class="nt"&gt;&amp;lt;/Button&amp;gt;&lt;/span&gt;&lt;br&gt;
  &lt;span class="nt"&gt;&amp;lt;/CardActions&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;span class="nt"&gt;&amp;lt;/Card&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusions&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;Material UI is an extensive library. It can take some time to get used to, but it's very powerful. By integrating MUI into a project, developers can speed up their workflow while maintaining a high standard of design and functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://mui.com/material-ui/" rel="noopener noreferrer"&gt;Material UI Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/mui/material-ui/tree/v4.x/docs/src/pages/getting-started/templates/album" rel="noopener noreferrer"&gt;Album Template&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Reinforcing Reinforcement Learning</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 12 Aug 2024 13:35:17 +0000</pubDate>
      <link>https://dev.to/dakota_day/reinforcing-reinforcement-learning-5g17</link>
      <guid>https://dev.to/dakota_day/reinforcing-reinforcement-learning-5g17</guid>
      <description>&lt;p&gt;Welcome to the third part of my machine learning series! In this blog, we'll cover some of the basics of the final learning pattern, &lt;strong&gt;reinforcement learning(RL)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Necessary Parts
&lt;/h2&gt;

&lt;p&gt;We'll start by talking about the key pieces inside of reinforcement learning. RL focuses on an agent being able to interact with an environment and make decisions. These decisions are based on how the agent is able to gain reward from its actions. The goal? Get as much reward as the agent can! &lt;br&gt;
The parts defined are this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Agent&lt;/strong&gt;: Defined as the thing learning, or moving through the environment. For example, in video games like Pong or Super Mario, the agent would be the paddle or Mario himself!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Environment&lt;/strong&gt;: This concerns everything that the agent interacts with. In video games, the level you're currently in would be the environment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Actions&lt;/strong&gt;: These are choices that our agent can take, these will change for every agent, as they all have different goals. In Pong, the goal is to score by hitting the ball, so actions for the paddle are up and down. Mario on the other hand, has a more complicated environment, and he's able to run, jump, go down pipes, etc. So his actions would include up, down, left, and right!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;State&lt;/strong&gt;: This is a snapshot of the environment at any given time. This is how the agent can "see" the environment as we would. State is important because it gives context for the agent's decision making. Mapping different states to actions that give consecutive rewards is the goal for the agent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rewards&lt;/strong&gt;: This represents a function that provides feedback from the environment. This is a crucial part of RL because this will cause the agent to act the way it does. You don't want to only think about giving the agent rewards for doing something good. You should also make sure that take away rewards for doing something undesirable.&lt;br&gt;
Let's take Mario for example again. Starting off, since the goal is to move right(to the flag and beat the level), we may give him rewards for moving right. In the first level, there is a goomba and pipe that would impede his progress immediately. To make sure that he learns to jump over the goomba, we want to take away from his reward on a death. For the pipe, we may want to make it so that every second that passes, Mario will lose a "point". This encourages him to move to the flag in the most efficient way possible.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Piece it Together
&lt;/h2&gt;

&lt;p&gt;So how do all of those pieces come together?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4wsiljrxpa26fexjs40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4wsiljrxpa26fexjs40.png" alt="Basic Diagram of RL" width="800" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This diagram shows the basic process our agent takes while learning.&lt;/p&gt;

&lt;h4&gt;
  
  
  Starting
&lt;/h4&gt;

&lt;p&gt;When learning a new video game, how do we, as humans, learn how to play? Well, if the game doesn't have any tutorials, we typically start by pressing all the buttons to see what they do. Our agent actually starts by doing something similar. Since the agent doesn't know how to get rewards, it takes random actions until it finds actions that give it multiple rewards.&lt;/p&gt;

&lt;h4&gt;
  
  
  Feedback
&lt;/h4&gt;

&lt;p&gt;While the agent takes those random actions, it gets feedback from the environment. Over time, the agent will adjust its actions to get more rewards while trying to minimize penalties. It takes the actions that got it rewards or actions that penalized it and the state where it took those actions, and passes it to the next "generation". Each generation bases its decisions on past generations' decisions, making it more probable to take those "good" actions to get the rewards it craves.&lt;/p&gt;

&lt;h4&gt;
  
  
  Policy
&lt;/h4&gt;

&lt;p&gt;This is simply a term to describe the agent's strategy. This would be the mapping function for states and actions. It would take a given state as an input, and outputs the best action for that state. The policy function changes drastically for every algorithm, and depending on the problem, can be difficult to solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exploration vs. Exploitation
&lt;/h2&gt;

&lt;p&gt;Exploration or exploitation? That is the choice that the agent has to make: should it take new actions(exploration), or take actions it already knows to give it rewards(exploitation).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exploration&lt;/strong&gt;: An agent may take actions the it doesn't normally take to gather new information in a given state. The benefit of this is to potentially find a better policy than it currently has. A downside of this, however, is that exploration can lead to immediate reward "dry spells" over long term rewards.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exploitation&lt;/strong&gt;: The agent may also take actions that it knows to give immediate rewards. This is necessary for the agent to get high rewards based on its past actions, resulting in high immediate rewards. The downside here is that the agent knows actions to give it rewards, so it won't explore new, potentially better, options.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One major challenge is achieving balance of these two concepts. A popular strategy one could use is called the &lt;strong&gt;Epsilon(ε)-Greedy Strategy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vmncpzf1t1yvmvuvgq9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vmncpzf1t1yvmvuvgq9.png" alt="Epsilon(ε)-Greedy Strategy" width="287" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This strategy gives the agent a chance to explore, ε(something small, say 0.1), and chance to exploit, (1 - ε). Here, 90% of the time, the agent will take the action it knows will give it immediate reward. That last 10% will be used taking a new, unexplored action. You can also make it so that as time progresses, ε reduces, and the agent takes less exploring actions, since after a certain point, there can't be better actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applications of RL&lt;/strong&gt;&lt;br&gt;
Reinforcement learning can be used in many parts of life. From self driving cars to natural language processing. We already know it has applications in gaming from my previous examples. In healthcare, it can be used to give treatments to patients based on policies learned from RL systems. That's just to name a few, check out &lt;a href="https://neptune.ai/blog/reinforcement-learning-applications" rel="noopener noreferrer"&gt;this blog&lt;/a&gt; by Derrick Mwiti to more deeply explore some other applications.&lt;/p&gt;

&lt;h5&gt;
  
  
  Conclusions
&lt;/h5&gt;

&lt;p&gt;So, what is the take-away? RL is a powerful tool that enables machines to learn from their own experiences. Agents learn to make decisions in an environment by exploring the best actions to take. It is already used in many parts of our lives and always getting better!&lt;/p&gt;

&lt;p&gt;Sources:&lt;br&gt;
&lt;a href="https://www.analyticsvidhya.com/blog/2021/02/introduction-to-reinforcement-learning-for-beginners/#:~:text=Reinforcement%20learning%20is%20a%20method,achieve%20its%20goals%20over%20time." rel="noopener noreferrer"&gt;What is Reinforcement Learning&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=JgvyzIkgxF0" rel="noopener noreferrer"&gt;An Introduction to Reinforcement Learning&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.baeldung.com/cs/epsilon-greedy-q-learning" rel="noopener noreferrer"&gt;Epsilon-Greedy Q-learning&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://neptune.ai/blog/reinforcement-learning-applications" rel="noopener noreferrer"&gt;10 Real-Life Applications of Reinforcement Learning&lt;/a&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Exploring Unsupervised Learning in ML</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 05 Aug 2024 01:18:00 +0000</pubDate>
      <link>https://dev.to/dakota_day/exploring-unsupervised-learning-in-ml-4hf</link>
      <guid>https://dev.to/dakota_day/exploring-unsupervised-learning-in-ml-4hf</guid>
      <description>&lt;p&gt;In my last blog I talked about machine learning(ML), its uses, and some of the different algorithmic patterns that make it work. In this blog we'll be checking out some unsupervised learning patterns and why we may want to use them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fth2nz4quso3llh0k5y61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fth2nz4quso3llh0k5y61.png" alt="Image description" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To quickly review, unsupervised learning uses algorithms to analyze &lt;strong&gt;unlabeled&lt;/strong&gt; data without our supervision. We'll look at three popular unsupervised learning patterns in this blog.&lt;/p&gt;

&lt;h2&gt;
  
  
  K-Means Clustering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ssz36nm01himc0pbrkx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ssz36nm01himc0pbrkx.gif" alt="Image description" width="247" height="240"&gt;&lt;/a&gt;&lt;br&gt;
We'll start by talking about K-means clustering. So what does the 'k' mean? The k represents the number of clusters we want in our data. K-means algorithms focus primarily on minimizing distances between data points and our clusters, in other words, data points within a distance belong to a certain cluster. This algorithm can be broken down into 5 steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialization&lt;/strong&gt;: Start with random K-points from the dataset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Assignment&lt;/strong&gt;: For every data point, we want to calculate the distance to each K-point and assign it to the closest one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Update K-points&lt;/strong&gt;: After assignment, we then want to recalculate the K-points position by looking at the relevant clustered data points and moving to the center of the cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Repeat&lt;/strong&gt;: We want to iterate steps 2 and 3 until our K-points no longer make significant movement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Results&lt;/strong&gt;: At the end the algorithm will output the final K points and each data point associated with them.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some applications of K-means algorithms include image segmentation in healthcare and robotics, marketing and retail to segment customers by purchase history and demographic, fraud detection, and recommendation systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Principal Component Analysis(PCA)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9vt2ji0bvkv3r4xf3u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9vt2ji0bvkv3r4xf3u5.png" alt="Image description" width="512" height="203"&gt;&lt;/a&gt;&lt;br&gt;
PCA can used alongside other techniques, but its objective is to simplify data by breaking large datasets into smaller ones. It does this while still maintaining patterns and trends, aka principal components. Let's go over the steps PCA follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Standardization&lt;/strong&gt;: This step is to ensure that large ranges of variables do not dominate smaller ranges. Bringing all variables to scale ensures no biased results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Covariance Matrix&lt;/strong&gt;: Here we make a matrix to compare each pair of features in the data. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Eigenvalue Decomposition&lt;/strong&gt;: Trying to keep it relatively simple, eigenvectors indicate the directions of maximum variance in the data and eigenvalues quantify the variance captured by each principal component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selecting Principal Components&lt;/strong&gt;: We sort eigenvalues in descending order and keep only the top n required principal components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Project the data&lt;/strong&gt;: Now we project the original data onto the dimensions represented by the principal components selected in the last step.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Applications for PCA include visualizing multidimensional data, reducing dimensions of data and resizing images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Autoencoders
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw6vprfo5gm758evntrj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flw6vprfo5gm758evntrj.png" alt="Image description" width="800" height="455"&gt;&lt;/a&gt;&lt;br&gt;
Autoencoders a special kind of neural network that is almost self supervised. They are made with an encoder and a decoder in mind.&lt;/p&gt;

&lt;h3&gt;
  
  
  Encoder
&lt;/h3&gt;

&lt;p&gt;The encoder compresses the input data and generates a bottleneck in the hidden layer of the neural network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Decoder
&lt;/h3&gt;

&lt;p&gt;The decoder tries to reconstruct the input, however it only has the compressed data to go off of. The output can 'improved' by calculating the reconstruction error between the input and output.&lt;/p&gt;

&lt;p&gt;Applications for autoencoders include image and audio compression, anomaly detection, data generation, and recommendation systems.&lt;/p&gt;

&lt;p&gt;In conclusion, unsupervised learning is helpful for picking up patterns we as humans may not notice as quickly. These algorithms are better suited for complex tasks or larger datasets.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sources
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.analyticsvidhya.com/blog/2019/08/comprehensive-guide-k-means-clustering/" rel="noopener noreferrer"&gt;Intro to K-Means Clustering&lt;/a&gt;&lt;br&gt;
&lt;a href="https://builtin.com/data-science/step-step-explanation-principal-component-analysis#:~:text=Principal%20component%20analysis%20(PCA)%20is%20a%20dimensionality%20reduction%20and%20machine,maintaining%20significant%20patterns%20and%20trends." rel="noopener noreferrer"&gt;Principal Component Analysis&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.datacamp.com/tutorial/introduction-to-autoencoders" rel="noopener noreferrer"&gt;Intro to Autoencoders&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Images Used
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://commons.wikimedia.org/wiki/File:K-means_convergence.gif" rel="noopener noreferrer"&gt;K-Means Graph&lt;/a&gt;&lt;br&gt;
&lt;a href="http://www.nlpca.org/fig_pca_principal_component_analysis.png" rel="noopener noreferrer"&gt;PCA Graph&lt;/a&gt;&lt;br&gt;
&lt;a href="https://towardsdatascience.com/applied-deep-learning-part-3-autoencoders-1c083af4d798" rel="noopener noreferrer"&gt;Autoencoder Graph&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>What is Machine Learning?</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 29 Jul 2024 02:58:33 +0000</pubDate>
      <link>https://dev.to/dakota_day/what-is-machine-learning-4g77</link>
      <guid>https://dev.to/dakota_day/what-is-machine-learning-4g77</guid>
      <description>&lt;p&gt;When I first hear the words 'machine learning', I think "AI that has the ability to grow more accurate over time". &lt;/p&gt;

&lt;p&gt;While my first thoughts feel fairly accurate, IBM gives us a more direct definition: "A branch of AI and computer science that focuses on using data and algorithms to enable AI to imitate the way that humans learn, gradually improving its accuracy."&lt;br&gt;
Given that information, how does it work?&lt;/p&gt;
&lt;h3&gt;
  
  
  Algorithms
&lt;/h3&gt;

&lt;p&gt;Machine learning is a pretty broad topic when looking at models and algorithms. We can break them down by looking at the ways they learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Supervised Learning&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgv4wwxe5dqrwxdmo9ws9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgv4wwxe5dqrwxdmo9ws9.png" alt="Supervised Learning" width="800" height="482"&gt;&lt;/a&gt;&lt;br&gt;
Uses &lt;strong&gt;labeled&lt;/strong&gt; datasets to train algorithms to predict outcomes and recognize patterns. We, the "supervisor", provide the dataset and the desired outcomes.&lt;br&gt;&lt;br&gt;
Some popular algorithms that use this technique are:&lt;br&gt;
--Naive Bayes Classifier&lt;br&gt;
--Decision Trees&lt;br&gt;
--K Nearest Neighbors&lt;br&gt;
--Linear Regression&lt;br&gt;
--Neural Networks&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unsupervised Learning&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8pcmiba18c6n7geu711.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8pcmiba18c6n7geu711.png" alt="Unsupervised Learning" width="800" height="297"&gt;&lt;/a&gt;&lt;br&gt;
Uses &lt;strong&gt;unlabeled&lt;/strong&gt; datasets to learn for itself.&lt;br&gt;
Since the datasets are unlabeled, the algorithms can only use &lt;em&gt;clustering&lt;/em&gt; or &lt;em&gt;association&lt;/em&gt; techniques to group similar inputs together&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reinforcement Learning&lt;/strong&gt;
Algorithms here are reward based. That means the program makes decisions on whether it gains or loses rewards. &lt;strong&gt;Positive reinforcement&lt;/strong&gt; occurs when an event happens due to a certain behavior, that behavior increases strength or frequency. &lt;strong&gt;Negative reinforcement&lt;/strong&gt; strengthens a behavior when a negative condition is avoided. The learning for this technique is iterative, so it learns from its mistakes and passes along the knowledge to the next generation. Think of those AI that are made to speedrun videogames!&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Neural Networks
&lt;/h3&gt;

&lt;p&gt;We'll take a look at neural networks. Neural networks are designed to to mimic our own brain's thought patterns. They can be used to do things like recognize patterns in speech, translating, and much more! They learn from whatever data is input and make predictions based on that data, growing more accurate the more data there is. I'll be using a simple program, courtesy of the LearnCode.academy YouTube channel, to show off how neural networks work. &lt;/p&gt;

&lt;p&gt;For our example program we'll have some html that has a color picker input that will set our background color and some example text that is white by default.&lt;/p&gt;
&lt;h4&gt;
  
  
  Brain.js
&lt;/h4&gt;

&lt;p&gt;Brain.js is a JavaScript library used for making neural networks, and we'll be using it for our program.&lt;/p&gt;

&lt;p&gt;A neural network, can be used to determine if a background is too dark or too light, and change the color of text to make it more readable.&lt;/p&gt;
&lt;h5&gt;
  
  
  Making the brain
&lt;/h5&gt;

&lt;p&gt;Let's start by making our brain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//this initializes a new neural network
const network = new brain.NeuralNetwork();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy enough.&lt;/p&gt;

&lt;h5&gt;
  
  
  Brain Training
&lt;/h5&gt;

&lt;p&gt;Human brains learn from information given to them, neural networks are the same. We can use the &lt;strong&gt;.train&lt;/strong&gt; method on the network. This is essentially what the network will use to predict outcomes. In our case, this will determine whether or not to change our text color. Let's give our network some starting data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//.train takes an array that holds our test data as a parameter
network.train([

//we can get our rgb values by dividing a color's values by 255
//the output should be what you think the background is: light or dark in this case
{input: {r: 0, g: 1, b: 0}, output: {light: 1}},
{input: {r: 0.33, g: 0.24, b: 0.29}, output: {dark: 1}},
]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's do the event listener for our color input! This is where we'll be determining whether the background is light or dark.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input.addEventListener('input', (color) =&amp;gt; {
  //this is just a helper function that converts hex color data to rgb values
  const rgb = getRgb(color.target.value);

  //we set the background color here
  text.style.background = color.target.value

  const result = brain.likely(rgb, network);

  text.style.color = result === 'dark' ? 'white' : 'black'
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So let's say we want to make our result be either our light value, or our dark value. Brain.js has a method we can use here as well. The &lt;strong&gt;.likely&lt;/strong&gt; method takes our rgb value and neural network as arguments. &lt;strong&gt;.likely&lt;/strong&gt; will then compare the likely hoods of the color being light or dark for us, using the data that we trained it with!&lt;/p&gt;

&lt;p&gt;If we were to try and display this on the page we would have some weird things going on. We only provided two inputs for our training data, so our network may have some issues trying to figure out if some rgb combinations are light or dark.&lt;/p&gt;

&lt;p&gt;Fixing this is easy! All we do is add more data to train the brain!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{input: {r: 0, g: 1, b: 0}, output: {light: 1}},
{input: {r: 0.33, g: 0.24, b: 0.29}, output: {dark: 1}},
{input: {r: 0.62, g: 0.72, b: 0.88}, output: {light: 1}},
{input: {r: 0.1, g: 0.84, b: 0.72}, output: {light: 1}},
{input: {r: 0.74, g: 0.78, b: 0.86}, output: {light: 1}},
{input: {r: 0.31, g: 0.35, b: 0.41}, output: {dark: 1}},
{input: {r: 0, g: 1, b: 0.65}, output: {light: 1}},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this training data, our brain will be able to more accurately predict whether the background is light or dark.&lt;/p&gt;

&lt;p&gt;The more you think about it, machine learning is used in &lt;strong&gt;a lot&lt;/strong&gt; of different areas of our life: recommendation systems, social media connections, image recognition and many more. I think it would be fairly safe to say that machine learning has greatly improved different facets of our lives. And the best part? It can only get better from here!&lt;/p&gt;

&lt;p&gt;Check out the sources used if you want to learn more:&lt;br&gt;
&lt;a href="https://www.ibm.com/topics/machine-learning" rel="noopener noreferrer"&gt;What Is Machine Learning (ML)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.simplilearn.com/10-algorithms-machine-learning-engineers-need-to-know-article" rel="noopener noreferrer"&gt;Top 10 Machine Learning Algorithms For Beginners: Supervised, and More&lt;/a&gt;&lt;br&gt;
&lt;a href="https://cloud.google.com/discover/what-is-supervised-learning" rel="noopener noreferrer"&gt;What is Supervised Learning?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://cloud.google.com/discover/what-is-unsupervised-learning" rel="noopener noreferrer"&gt;What is Unsupervised Learning?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/what-is-reinforcement-learning/" rel="noopener noreferrer"&gt;What is Reinforcement Learning&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/BrainJS/brain.js?tab=readme-ov-file#brainjs" rel="noopener noreferrer"&gt;Brain.js Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=9Hz3P1VgLz4" rel="noopener noreferrer"&gt;Machine Learning Tutorial for Beginners - USING JAVASCRIPT!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Images used:&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/ml-types-learning-part-2/" rel="noopener noreferrer"&gt;Unsupervised Learning&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/supervised-unsupervised-learning/" rel="noopener noreferrer"&gt;Supervised Learning&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>learning</category>
      <category>machinelearning</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Python vs. JavaScript</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Mon, 03 Jun 2024 11:57:20 +0000</pubDate>
      <link>https://dev.to/dakota_day/python-vs-javascript-3cpl</link>
      <guid>https://dev.to/dakota_day/python-vs-javascript-3cpl</guid>
      <description>&lt;p&gt;Python and JavaScript (JS) are two fairly old programming languages at this point, but what makes them different from each other? Many would consider these languages fairly beginner friendly. How are they similar? We'll go over a couple of things that set these two languages apart and why they've been in the game for so long.&lt;/p&gt;

&lt;h2&gt;
  
  
  Humble Beginnings
&lt;/h2&gt;

&lt;p&gt;Both languages in this post are very mature and rooted, being made in the early days of 90's public internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;

&lt;p&gt;Python was developed by &lt;em&gt;Guido van Rossum&lt;/em&gt; starting in 1989 but wouldn't be released until 1991. Funny enough according to Python Institute, the name is derived from Monty Python's Flying Circus! Python is maintained by Python Software Foundation. It was built with a couple things in mind: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Being easy to learn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Being easy to read and write.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And being easy to obtain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;

&lt;p&gt;JavaScript is slightly younger, being developed in 1995 by Netscape programmer, &lt;em&gt;Brendan Eich&lt;/em&gt;. Here's a fun fact, Brendan Eich built JS in 10 days! It was originally called Mocha, then LiveScript, and finally the JavaScript we all know today. In 1997, Netscape would hand off JS management and maintenance to the European Computer Manufacturers Association (ECMA). The newly handled versions would be called ECMAScript or ES. The standardized version now is ES6(2015) which added a lot of features that devs had been asking for. If we were to compare it directly to Python for comparison sake:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Also easy to learn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Slightly harder to read and write.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also fairly easy to obtain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7fqsnen9crspgca8f3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7fqsnen9crspgca8f3c.png" alt="Tiobe Top Languages Chart May 2024" width="800" height="212"&gt;&lt;/a&gt;&lt;br&gt;
According to Tiobe.com, Python is the most popular coding language sitting at a crazy 16.33% approval rating as of May 2024! It even won Tiobe's Language of the Year in 2007, 2010, 2018, 2020, and 2021. JavaScript, while not as high, still sits in the top 10 at number 6 with a 3.01% approval rating. It also won Language of the Year in 2014. Learning either one of these won't give you any difficulty landing a job.&lt;/p&gt;


&lt;h2&gt;
  
  
  Let's Talk Syntax
&lt;/h2&gt;

&lt;p&gt;Python and JS are both fairly easy to write, but what are some key differences in the syntax? Python is known for its high readability, almost pseudocode-like structure. JS on the other hand is more known for it's flexibility. Here's some example syntax on how you would write some basic code in each language:&lt;/p&gt;
&lt;h4&gt;
  
  
  Variables
&lt;/h4&gt;

&lt;p&gt;In Python, variables aren't defined with keywords, just set them to whatever data type you need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = 10 #Python uses # for comment lines
string = 'hello' #It doesn't require semicolons to end lines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In JS, it is best practice to use declarative keywords, like &lt;em&gt;let&lt;/em&gt; and &lt;em&gt;const&lt;/em&gt;, when making variables. Not doing so can lead to scope issues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let num = 10;
let string = 'hello';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Functions
&lt;/h4&gt;

&lt;p&gt;Python uses the &lt;em&gt;def&lt;/em&gt; keyword to define a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add(num1, num2): #Python uses colons to indicate new blocks
  result = num1 + num2
  print(result) #It also uses print() for printing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JS uses either the &lt;em&gt;function&lt;/em&gt; keyword or &lt;em&gt;arrow function&lt;/em&gt; syntax. Arrow functions give the option to shorten function blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(num1, num2){
  result = num1 + num2
  return console.log(result) //JS uses console.log() for logging
}
//OR
add (num1, num2) =&amp;gt; console.log(num1 + num2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Conditionals
&lt;/h4&gt;

&lt;p&gt;Python &lt;strong&gt;does not&lt;/strong&gt; use curly braces to define blocks like JS. Instead it uses &lt;em&gt;indentation&lt;/em&gt; to define its blocks. This changes how conditionals look of course. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if num &amp;lt; 0:
  print('negative')
elif num === 0: #Python uses elif instead of JS's _else if_
  print('zero')
else:
  print('positive')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's JS's version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (num &amp;lt; 0){ // Here the conditions must be wrapped in parentheses
  console.log('negative')
} else if (num === 0){ //Braces to indicate code blocks
  console.log('zero')
} else{
  console.log('positive')
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just in these simple examples you can see how Python really strives to make coding faster and more readable.&lt;/p&gt;

&lt;p&gt;Here's a video from &lt;em&gt;Red Eyed Coder Club&lt;/em&gt; that shows how a basic algorithm would be built side by side in both languages:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Jld0aUQ9LZw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Case
&lt;/h2&gt;

&lt;p&gt;Where Python and JS start to break apart from each other is each of their use cases. JS focuses more on front-end development while Python focuses more on the back-end side of things.&lt;/p&gt;

&lt;h3&gt;
  
  
  Javascript
&lt;/h3&gt;

&lt;p&gt;JS is used alongside HTML and CSS a lot of the time. This means that you can find yourself building functional websites and applications on the back-end that are also pleasing to the eye on the front-end. This is reflected in the frameworks and libraries JS offers, some of the most popular frameworks being React, Vue, and Angular. If you enjoy this, that probably means you would want to go for full-stack dev positions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;

&lt;p&gt;Python, being more back-end focused, is primarily used for things like scripting and automation. Its frameworks and libraries will focus more on data sciences or automation tasks. Some popular ones are Pandas, NumPy, and Scikit Learn.&lt;/p&gt;

&lt;p&gt;Now don't get it twisted, just because one language has a focus in one area doesn't mean that you can't use it at all for a weaker one. Just keep in mind that if you were to go that route, you may just have more trouble, or take more time trying to get things to work correctly.&lt;/p&gt;

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

&lt;p&gt;So what does all of this mean? Well, when thinking about jobs or projects that you want to do, picking a language can make those projects significantly harder or easier. Python will shine working on the back-end while JavaScript will shine while working on the front-end. Neither one is necessarily a better choice over the other, it just depends on what &lt;strong&gt;YOU&lt;/strong&gt; want to do. Most people after learning one will go and learn the other. After all, coding languages are just tools, and having different tools will make you more desirable as a new hire.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sources Used
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.springboard.com/blog/data-science/history-of-javascript/"&gt;The History of JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Brendan_Eich#:~:text=He%20completed%20the%20first%20version,was%20named%20JavaScript%20in%20December."&gt;Brendan Eich&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pythoninstitute.org/about-python#:~:text=Python%20was%20created%20by%20Guido,called%20Monty%20Python's%20Flying%20Circus."&gt;About Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/python/python_syntax.asp"&gt;W3Schools&lt;/a&gt; For Python syntax &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tiobe.com/tiobe-index/"&gt;Tiobe Index&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=t9CAFYn7YgY"&gt;Tech With Tim on Youtube&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>What's the Deal with Arrays and Objects?</title>
      <dc:creator>Dakota Day</dc:creator>
      <pubDate>Fri, 19 Apr 2024 21:20:26 +0000</pubDate>
      <link>https://dev.to/dakota_day/whats-the-deal-with-arrays-and-objects-5dlj</link>
      <guid>https://dev.to/dakota_day/whats-the-deal-with-arrays-and-objects-5dlj</guid>
      <description>&lt;p&gt;We all know arrays and objects, right? Sure, but what are some key differences between the two? Let's start with some ways that the two are similar: well, they're both &lt;strong&gt;&lt;em&gt;complex&lt;/em&gt;&lt;/strong&gt; data types for starters, meaning that they can hold a multitude of &lt;strong&gt;&lt;em&gt;other&lt;/em&gt;&lt;/strong&gt; datatypes within themselves, including other arrays and objects! Both also a have way to loop through the data they contain.&lt;/p&gt;

&lt;p&gt;Here's two examples that we'll use throughout this reading:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let dataTypesArr = ['string', 1, true, ['array'], {key: 'value'}];

let dataTypesObj = {
  string: 'string',
  number: 4,
  boolean: true,
  array: [1, 2, 3],
  object: {inner: true}
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Access... Granted?
&lt;/h3&gt;

&lt;p&gt;We now know that these two datatypes can hold other datatypes, but how do we access them? This is where some key differences begin to show.&lt;/p&gt;

&lt;h4&gt;
  
  
  Arrays
&lt;/h4&gt;

&lt;p&gt;Arrays can be accessed by using &lt;em&gt;&lt;strong&gt;bracket&lt;/strong&gt;&lt;/em&gt; notation. Since arrays can have their data organized, they contain an index which keeps track of what is where. They also have a length property which is handy for looping.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(dataTypesArr[0]); //This prints the value held at the
                              //0 index which is 'string' here

//For loops allow us to access all of the data if we wanted to
for(let i = 0; i &amp;lt; dataTypesArr.length; i++){
  console.log(dataTypesArr[i])
}
//This loop prints whatever value is held at the i index during
//that iteration, and it runs until it is out of data to iterate
//through
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Objects
&lt;/h4&gt;

&lt;p&gt;Objects have the ability to be accessed using bracket &lt;em&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;/em&gt; dot notation. Keep in mind if you decide to use bracket notation for accessing objects, you have to include the quotes inside the brackets to notate you want to access that literal keyName. They do not have a length property and their data is not organized. Objects also have a special way to loop through their stored data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(dataTypesObj.number); //Prints value held at the 
                                  //'number' key, which is 4
console.log(dataTypesObj['boolean']); //Prints value held at the 
                                    //'boolean' key, which is true

//To loop through an object, you have to use a for-in loop
for(let key in dataTypesObj){
  console.log(key); //This prints all of the keys
  console.log(dataTypesObj[key]);
} 
//Here you wouldn't put key in quotes because key is used as a
//variable. If you used quotes, the program would try to find the
//key named 'key'. This will print all of the values held at each
//key.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Manipulation?
&lt;/h3&gt;

&lt;p&gt;Now we know how to access them, but how can we manipulate the data with arrays and objects? Easy, actually. Both types have their own ways to change, or &lt;em&gt;&lt;strong&gt;mutate&lt;/strong&gt;&lt;/em&gt;, their data&lt;/p&gt;

&lt;h4&gt;
  
  
  Arrays
&lt;/h4&gt;

&lt;p&gt;Starting with arrays again, you can put new data in, or take it out. People most commonly use &lt;em&gt;array methods&lt;/em&gt; to accomplish this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//.push() and .unshift() add data to the end and beginning of the
//array respectively
datatypesArr.push(5); //adds 5 to the end of the array
datatypesArr.unshift(10); //adds 10 to the beginning of the array

//.pop() and .shift() remove data from the end and beginning of
//the array respectively
datatypesArr.pop(); //removes the last value
datatypesArr.shift(); //removes the first value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Objects
&lt;/h4&gt;

&lt;p&gt;Objects are really easy to manipulate, no methods needed!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Say we want to add a new piece of data called name
dataTypesObj.name = 'Dakota'; //Adds new key/value pair:
                              //name: 'Dakota'
dataTypesObj['age'] = 27; //Also works with bracket notation!

//If we wanted to delete our newly created data, just use the
//delete keyword
delete dataTypesObj.name; //deletes name: 'Dakota'
delete dataTypesObj['age']; //deletes age: 27
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;Just remember, arrays and objects are really only similar in the way that they are complex data types and that they can loop. They each have their own ways to loop, access, and manipulate the inner data. Hopefully this information helps if you're struggling to get the hang of arrays and objects. Good luck on your own coding adventure!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
