<?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: Joseph Muchai</title>
    <description>The latest articles on DEV Community by Joseph Muchai (@muchai_joseph).</description>
    <link>https://dev.to/muchai_joseph</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%2F1496708%2F02cb58ee-daf8-4953-ad48-de108f635b80.png</url>
      <title>DEV Community: Joseph Muchai</title>
      <link>https://dev.to/muchai_joseph</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muchai_joseph"/>
    <language>en</language>
    <item>
      <title>Understanding Tanstack Query: A Brief Guide</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Thu, 07 Aug 2025 08:49:59 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/understanding-tanstack-query-a-brief-guide-4dj5</link>
      <guid>https://dev.to/muchai_joseph/understanding-tanstack-query-a-brief-guide-4dj5</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine you're running a busy coffee shop, and every time a customer orders, you have to check the stockroom for ingredients, update the inventory, and serve the coffee, all while keeping the line moving. Managing all this manually can get chaotic.&lt;/p&gt;

&lt;p&gt;React applications, fetching and managing data from a server is a similar challenge. You have to juggle loading states, error handling, and even cache management.&lt;/p&gt;

&lt;p&gt;Tanstack Query (formerly React Query) makes all of these easier. It's a powerful library that simplifies how you fetch, cache, and update data in your React apps, making them faster and more reliable. Instead of manually writing &lt;code&gt;useEffect&lt;/code&gt; hooks, managing multiple state variables, and implementing caching logic from scratch, TanStack Query provides hooks that automatically handle loading states, error management, background updates, and intelligent caching&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Concepts
&lt;/h2&gt;

&lt;p&gt;At its heart, TanStack Query revolves around two main concepts: queries for fetching data and mutations for updating data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Queries in Tanstack Query are like having a personal assistant who manages your app's data. When you use the useQuery hook, you're telling your assistant, "Fetch this data, keep it up to date, and let me know if anything changes." This means Tanstack Query handles all the hard work behind the scenes. It stores the data (caching) to avoid unnecessary requests to the server and refreshes it when it's outdated. This keeps your app fast and your code simple.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Query keys in Tanstack Query are like labels on folders in a filing cabinet. Each label uniquely identifies a specific set of data, so Tanstack Query knows exactly which data you're asking for. When the key changes, it triggers the fetching of a different set of data. This system ensures your data stays synchronized with your UI state&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mutations handle data updates: creating, updating, or deleting server data. Unlike queries that run automatically, mutations only execute when you explicitly trigger them, like when a user submits a form. You use the useMutation hook to define the update operation, specifying how to send the request (e.g., via axios.post). The hook provides tools to track loading or error states and can refresh related queries to keep your app's data consistent after the update.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example:
&lt;/h2&gt;

&lt;p&gt;Let's build a simple React app that fetches some user data from a public API using Tanstack Query.&lt;br&gt;
First, set up the query client in your main app file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

const queryClient = new QueryClient()

function App() {
  return (
    &amp;lt;QueryClientProvider client={queryClient}&amp;gt;
      &amp;lt;UserList /&amp;gt;
    &amp;lt;/QueryClientProvider&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;p&gt;Now, fetch user data with remarkable simplicity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function UserList() {
  // Fetch data using useQuery
  const { data, isLoading, isError } = useQuery({
    queryKey: ['users'],
    queryFn: async () =&amp;gt; {
      const response = await axios.get('https://jsonplaceholder.typicode.com/users');
      return response.data;
    },
  });

  // Handle loading state
  if (isLoading) return &amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;;

  // Handle error state
  if (isError) return &amp;lt;div&amp;gt;Error: {error.message}&amp;lt;/div&amp;gt;;

  // Render data
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Users&amp;lt;/h1&amp;gt;
      &amp;lt;ul&amp;gt;
        {data.map(user =&amp;gt; (
          &amp;lt;li key={user.id}&amp;gt;{user.name}&amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;To break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Importing Dependencies&lt;/strong&gt;: We import React, Tanstack Query hooks, and axios for HTTP requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;QueryClient&lt;/code&gt; Setup&lt;/strong&gt;: We wrap our app in &lt;code&gt;QueryClientProvider&lt;/code&gt; to make it available everywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;useQuery&lt;/code&gt; Hook&lt;/strong&gt;: This hook fetches data. The &lt;code&gt;queryKey: ['users']&lt;/code&gt; uniquely identifies this data. The &lt;code&gt;queryFn&lt;/code&gt; defines how to fetch the data using axios.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Handling&lt;/strong&gt;: Tanstack Query gives us &lt;code&gt;isLoading&lt;/code&gt;, &lt;code&gt;isError&lt;/code&gt;, and data to manage the fetch process. We show "Loading…" while fetching, display errors if they occur, and render the user list when data arrives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rendering&lt;/strong&gt;: We map over the data array to display each user's name in a list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The beauty here is that TanStack Query automatically caches this data. If another component needs the same users list, it won't make another network request, it'll use the cached version instantly&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Pitfalls
&lt;/h2&gt;

&lt;p&gt;Some of the mistakes devs make when working with Tanstack Query are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copying TanStack Query data to Redux or Context&lt;/strong&gt;: Many developers coming from Redux backgrounds make the mistake of immediately dispatching TanStack Query results to their existing state management. This creates two sources of truth and defeats the purpose of using TanStack Query. A better way is to use the data from Tanstack Query directly instead of copying it elsewhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Misusing the refetch function:&lt;/strong&gt; Beginners often use &lt;code&gt;refetch()&lt;/code&gt;when they should be updating the query key. The &lt;code&gt;refetch&lt;/code&gt; function should only be used when you want to re-run the exact same query with identical parameters. When your parameters change (like filters or pagination), include them in your query key instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not understanding when queries run:&lt;/strong&gt; TanStack Query automatically refetches data in certain situations (like when the window regains focus), which can be surprising for newcomers. Configure &lt;code&gt;staleTime&lt;/code&gt; and &lt;code&gt;cacheTime&lt;/code&gt; to control when your data is considered fresh and how long it stays in cache. For data that doesn't change often, increase the &lt;code&gt;staleTime&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusing Query Keys&lt;/strong&gt;: Each query needs a unique &lt;code&gt;queryKey.&lt;/code&gt; Using the same key for different data can cause caching issues.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting Dependencies&lt;/strong&gt;: Ensure you install @tanstack/react-query and wrap your app in the &lt;code&gt;QueryClientProvider&lt;/code&gt;, or the hooks won't work.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;TanStack Query transforms React data fetching from a manual, error-prone process into an automated, reliable system. By handling caching, background updates, error states, and loading management automatically, it lets you focus on building features instead of managing data infrastructure.&lt;/p&gt;

&lt;p&gt;It's like having a helper who handles the messy parts of server communication, while you focus on building a great app. Start with small examples like the one above, and as you get comfortable, explore features like mutations (for updating data) or optimistic updates.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The only thing I'm confident enough to push on a Friday evening, check it out!</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Fri, 18 Jul 2025 13:05:10 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/the-only-thing-im-confident-enough-to-push-on-a-friday-evening-check-it-out-bbm</link>
      <guid>https://dev.to/muchai_joseph/the-only-thing-im-confident-enough-to-push-on-a-friday-evening-check-it-out-bbm</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84" class="crayons-story__hidden-navigation-link"&gt;Introduction to Web Design for Web Developers&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/muchai_joseph" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1496708%2F02cb58ee-daf8-4953-ad48-de108f635b80.png" alt="muchai_joseph profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/muchai_joseph" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Joseph Muchai
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Joseph Muchai
                
              
              &lt;div id="story-author-preview-content-2639263" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/muchai_joseph" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1496708%2F02cb58ee-daf8-4953-ad48-de108f635b80.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Joseph Muchai&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 18 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84" id="article-link-2639263"&gt;
          Introduction to Web Design for Web Developers
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/design"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;design&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              1&lt;span class="hidden s:inline"&gt; comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            17 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>design</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Introduction to Web Design for Web Developers</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Fri, 18 Jul 2025 12:59:28 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84</link>
      <guid>https://dev.to/muchai_joseph/introduction-to-web-design-for-web-developers-c84</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The web development scene has evolved significantly over the past few years, and the aesthetic essence of a website is now as important as its essential functionality. In today's digital landscape, the success of web applications relies not only on robust functionality but also on visually appealing and intuitive user interfaces. The binding of sleek design and efficient functionality enhances the overall usability and user experience, making it a key factor in the success of any web application.&lt;/p&gt;

&lt;p&gt;As a web developer, this emphasizes the need to develop a keen eye for web design and attain a solid grasp of user experience principles. Furthermore, given the competitive tech landscape, developers with web design skills stand out significantly. Not only can they create more intuitive and user-friendly interfaces, but they are also more versatile and valuable to employers, as they can contribute to both the technical and visual aspects of a project. Understanding design principles also fosters better communication and collaboration with designers, allowing for more seamless integration of design and development processes.&lt;/p&gt;

&lt;p&gt;This guide will serve as a basic introduction to web design. We'll delve into key web design principles such as visual design fundamentals, typography, color theory, and responsive design. We'll also explore how to cultivate a design mindset, leverage popular design tools like Figma, and integrate these tools into your development workflow.&lt;/p&gt;

&lt;p&gt;Let's dive right in!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Web Design Principles to Master
&lt;/h2&gt;

&lt;p&gt;We will begin by learning about the essential principles for good design. Just like in programming, there are a number of fundamental foundations of design that one should learn. Understanding and applying these principles will help you create cohesive, attractive, and intuitive interfaces.&lt;/p&gt;

&lt;p&gt;In this section, we will explore the fundamental aspects of visual design, typography, color theory, and responsive design.&lt;/p&gt;

&lt;h3&gt;
  
  
  Visual design principles
&lt;/h3&gt;

&lt;p&gt;Visual design principles are the fundamental guidelines that dictate how the basic elements of design, such as line, shape, color, texture, space, and volume, are organized and combined to create effective, aesthetically pleasing, and functional visual compositions.&lt;/p&gt;

&lt;p&gt;These principles help designers arrange elements in a way that communicates messages clearly, guides the viewer’s attention, and enhances usability.&lt;/p&gt;

&lt;p&gt;They include:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Contrast
&lt;/h4&gt;

&lt;p&gt;Contrast is the difference between two or more adjacent elements in a design. This difference allows some elements to stand out more than others, which helps create visual interest and draw attention to specific areas. It makes your design "POP".&lt;/p&gt;

&lt;p&gt;Contrast can be created using color, size, or shape. By applying contrast, you can guide the user's eye and highlight important information. High color contrast, for example, is used to highlight important buttons on a website.&lt;br&gt;
Insufficient contrast, on the other hand, especially when dealing with text, can result in poor readability and legibility issues.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fs6rdazlcpytesk4ishgu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fs6rdazlcpytesk4ishgu.png" alt="contrast example" width="800" height="380"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This website applies contrast by using a dark background with a bookshelf image against light text and a bright yellow headline, creating a striking visual hierarchy and emphasizing key elements.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Alignment
&lt;/h4&gt;

&lt;p&gt;Alignment involves arranging elements in a way that creates a visual flow and connection. It can help users understand how elements relate to each other by creating a sense of structure, harmony, and visual appeal.&lt;/p&gt;

&lt;p&gt;You can apply different types of alignment to various design aspects, such as typography, grid systems, and graphic elements. A good rule of thumb is to apply consistent alignment across interfaces. For example, you can choose to align all headings on a page to the left to create a sense of familiarity and predictability.&lt;br&gt;
Poor alignment in a design results in a page that looks cluttered and unfinished.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F440qjzp8545gmd5m52bu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F440qjzp8545gmd5m52bu.jpg" alt="alignment example" width="800" height="456"&gt;&lt;/a&gt;&lt;em&gt;This design applies alignment by organizing the "Latest Article" section with a consistent left-aligned text layout for the title and description, while the blog post previews are evenly spaced and centered within their respective cards, creating a structured and visually balanced grid.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Balance
&lt;/h4&gt;

&lt;p&gt;Balance refers to the distribution of visual weight in a design. It plays a crucial role in influencing where the viewer's eye lands and is most focused on. The visual weight of an element is based on its size, color, and texture.&lt;/p&gt;

&lt;p&gt;Elements with a higher visual weight (larger size, brighter color, etc.) draw the viewer's eye more than those with a lower visual weight. Hence, you should aim to create a sense of stability and harmony in your designs to ensure no part feels heavy or overwhelming compared to the rest.&lt;/p&gt;

&lt;p&gt;There are 2 main types of balance in web design: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symmetrical: Elements are mirrored on either side of a central axis, creating a formal and organized look. It is often used where order and predictability are key. For example, if you have a design where the left and right sides have equal visual weight, it feels stable and harmonious.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F8qefhj3p4f4wj75fqyrh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F8qefhj3p4f4wj75fqyrh.jpg" alt="symmetrical balance example" width="800" height="433"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The design features a central axis with the "Hardware Infrastructure" and "Management Tools" sections mirrored on either side, each with similar shapes, sizes, and layouts—both have a heading, descriptive text, and a linked word ("About firewall" and "Documentations") creating an even distribution of visual weight and a harmonious, mirrored composition.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asymmetrical: Elements of differing sizes, colors, or shapes that are arranged in a way that still creates a sense of equilibrium. Instead of mirroring, it relies on contrast and scale to achieve balance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhwxkeiel9ytra9w3a8zj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhwxkeiel9ytra9w3a8zj.jpg" alt="asymmetrical balance example" width="800" height="514"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This design achieves balance by distributing visual weight unevenly across the layout while maintaining harmony.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Hierarchical proximity
&lt;/h4&gt;

&lt;p&gt;This refers to the arrangement of design elements based on their importance and relationship. The closer the related elements are placed, the stronger the perceived connection between them. &lt;/p&gt;

&lt;p&gt;By creating a visual association between related items, information is rendered in a way that improves readability as well as understanding. For instance, placing headings close to corresponding text in designs not only ensures a logical flow through our pages but also a smoother user experience.&lt;/p&gt;

&lt;p&gt;In web design, we can apply hierarchical proximity by grouping related content, like text and images, to create clear sections, placing buttons near relevant actions to encourage clicks, organizing navigation menus logically, and spacing out unrelated elements to reduce clutter and improve readability.&lt;br&gt;
&lt;a href="https://media2.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%2Fidluk8xeaqrofo6onm9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fidluk8xeaqrofo6onm9y.png" alt="hierarchy example" width="614" height="608"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This design demonstrates hierarchical proximity by grouping the text "Find cheap flights and deals..." with the world map and hand graphic, and the building photo with the text "Book hotels, apartments, houses...", using tight spacing to create a clear visual hierarchy and guide the viewer's eye logically from flights to accommodations.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Repetition
&lt;/h4&gt;

&lt;p&gt;This is the use of the same or similar elements, such as colors, fonts, and shapes, throughout a composition to create unity and consistency. It is key in creating a cohesive and recognizable visual identity in our designs. &lt;/p&gt;

&lt;p&gt;By repeating certain visual elements such as colors, shapes, fonts, and patterns, we can create emphasis, drawing attention to key messages or features in a design. Repetition also helps convey a sense of familiarity, which fortifies the overall brand identity and creates a powerful, enduring presence. For instance, the strategic color repetition of Google in branding its applications.&lt;/p&gt;

&lt;p&gt;It can take various forms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pattern&lt;/strong&gt;: This involves the repeated use of identical or similar shapes and colors to create a visual rhythm. Patterns can enhance the aesthetic appeal of a design and contribute to its overall texture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rhythm&lt;/strong&gt;: In design, rhythm refers to the spacing and arrangement of repeated elements, creating a sense of movement and flow. This can guide the viewer's eye through the composition, making it more engaging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Visual Elements&lt;/strong&gt;: Repetition can be applied to specific visual components, such as icons, buttons, or typography, ensuring that these elements are consistently presented across a design or a series of designs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fepmfxkwleetb3uya2iq5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fepmfxkwleetb3uya2iq5.jpg" alt="repetition example" width="800" height="578"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This dashboard design from Donezo exemplifies repetition as a visual principle through consistent green buttons, uniform card layouts, and repeated circular avatars, creating a cohesive and unified user interface.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;Typography in web design refers to the skillful and deliberate selection, arrangement, and implementation of typefaces to enhance a website's aesthetic appeal and readability.&lt;/p&gt;

&lt;p&gt;Typography is crucial for readability, hierarchy, and branding. For example, choosing a clean sans-serif typeface like Roboto can create a modern, approachable tone, while a serif typeface like Georgia may evoke tradition and elegance. Clear typefaces improve comprehension, and strategic choices guide users’ attention while reflecting a site’s personality.&lt;/p&gt;

&lt;p&gt;Beyond aesthetics and readability, typography must prioritize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Skimmability&lt;/strong&gt;, as users often scan web pages for specific information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accessibility&lt;/strong&gt;, ensuring text is legible for all users, such as those using screen readers or requiring high-contrast displays.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple screen sizes&lt;/strong&gt;, making text clear and adaptable across devices, from smartphones to desktops.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, selecting a typeface is just the start. Decisions like line length (the width of a text block) and line height (the space between lines) significantly impact readability and user experience. Optimal line lengths, typically 50–75 characters, and balanced line heights prevent strain and ensure a cohesive design.&lt;/p&gt;

&lt;p&gt;Here are some guidelines to improve your typography implementations:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Pair fonts thoughtfully
&lt;/h4&gt;

&lt;p&gt;Use compatible typefaces, especially if they use different fonts within the typeface for different purposes, such as headings, body text, button text, etc. You can leverage tools like &lt;a href="https://fontjoy.com/" rel="noopener noreferrer"&gt;FontJoy&lt;/a&gt; and &lt;a href="https://typ.io/" rel="noopener noreferrer"&gt;Typ.io&lt;/a&gt; to get good font combination recommendations.&lt;br&gt;
&lt;a href="https://media2.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%2F5yc4q8abghsu3nx8ojit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5yc4q8abghsu3nx8ojit.png" alt="Preview of FontJoy" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Choose readable fonts
&lt;/h4&gt;

&lt;p&gt;Opt for clear, legible typefaces, for example, sans-serif fonts like Roboto, Open Sans, or serif fonts like Georgia for body text.&lt;br&gt;
Ensure fonts are optimized for digital screens, avoiding overly decorative or thin fonts that strain the eyes&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Establish a typographic hierarchy
&lt;/h4&gt;

&lt;p&gt;Use varying font sizes, weights (bold, regular, light), and styles to guide users through content, e.g., larger headings, smaller subheadings, and body text. &lt;br&gt;
This helps readers scan through pages for the target content.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Maintain proper contrast
&lt;/h4&gt;

&lt;p&gt;Ensure high contrast between text and the background, for example, dark text on light backgrounds or vice versa, for accessibility.&lt;br&gt;
Follow the Web Content Accessibility Guidelines (WCAG) guidelines on a minimum of 4.5:1 contrast ratio for most text and 3:1 for large, bolded text.&lt;br&gt;
Use free tools such as &lt;a href="https://colourcontrast.cc/" rel="noopener noreferrer"&gt;Colourcontrast.cc&lt;/a&gt; to check the contrast between your font and background color.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Use appropriate font sizes
&lt;/h4&gt;

&lt;p&gt;Set body text to between 16–24px for desktop and scale appropriately for mobile, e.g., 14–18px.&lt;br&gt;
Also, use responsive typography such as relative units like &lt;code&gt;rem&lt;/code&gt; or &lt;code&gt;vw&lt;/code&gt;, to adapt to different screen sizes.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Mind line spacing and length
&lt;/h4&gt;

&lt;p&gt;Set line height (leading) to 1.4–1.8 times the font size for comfortable reading and keep line lengths to 50–75 characters per line to avoid reader fatigue.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Test across all devices
&lt;/h4&gt;

&lt;p&gt;Preview typography on various devices and browsers to ensure consistency.&lt;br&gt;
Use tools like BrowserStack or Google DevTools to simulate different screen sizes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Color Theory
&lt;/h3&gt;

&lt;p&gt;Color theory is the art and science of how colors interact and affect human emotions and perceptions. In web design, color theory serves as a framework that enables you to pick colors that not only go well together but also convey the right mood and message in your website.&lt;/p&gt;

&lt;p&gt;It lets you guide visitors’ eyes to key elements, reinforcing a brand’s personality, and creating an emotional connection that keeps people engaged. When applied thoughtfully, color theory transforms a simple layout into an immersive experience.&lt;/p&gt;

&lt;p&gt;Some of the key concepts of Color theory you should be familiar with include:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. The Color Wheel and Relationships
&lt;/h4&gt;

&lt;p&gt;The color wheel is the basis of all color theory as it shows the relationship between colors. It was invented in 1666 by Isaac Newton by mapping the color spectrum onto a circle. &lt;/p&gt;

&lt;p&gt;There are 2 types of the color wheel:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;RYB&lt;/strong&gt;(red, yellow, blue) color wheel, typically used by artists, as it helps with combining paint colors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;RGB&lt;/strong&gt;(red, green, blue) color wheel, designed for digital screen use, as it refers to mixing light.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our main focus will be the &lt;strong&gt;RGB&lt;/strong&gt; color wheel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fro735cjyx6861pmtoh5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fro735cjyx6861pmtoh5j.png" alt="RGB color wheel" width="465" height="465"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;RGB color wheel.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By systematically categorizing colors, the &lt;strong&gt;RGB&lt;/strong&gt; color wheel defines three major color groups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Primary colors&lt;/strong&gt;: These are red, green, and blue. They form the bedrock of every color palette and give rise to every shade and tint you see. They cannot be created by mixing other colors. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Secondary colors&lt;/strong&gt;: These emerge when you blend 2 primaries. Red and green make yellow, green and blue make cyan, and blue and red make magenta.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tertiary colors&lt;/strong&gt;: These are formed by mixing a primary and a secondary color. They are 6 in total and include: orange, chartreuse green, spring green, azure, violet, and rose.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ft2fy0531tsimeri3kr4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ft2fy0531tsimeri3kr4k.png" alt="the 3 color groups" width="800" height="471"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://static-cse.canva.com/_next/static/assets/primary-secondary-and-tertiary-colors_w1324xh780_6fb07a8246eb45b851fefc587ef99e7615546640a5266ad9b7a13d3f211cd3be.png" rel="noopener noreferrer"&gt;Canva&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is from the above color groups and how they are aligned on the color wheel that we get key color relationships/schemes. These color schemes are what we use when creating a color palette for our designs. Some of them include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Complementary&lt;/strong&gt;: Complementary colors are opposite each other on the color wheel, for example, blue and orange. This combination provides a strong contrast, making things "pop". This is why it's great for highlighting key parts of your design. At full saturation, complementary hues can be extremely vibrant. Thus, it's advisable to moderate the intensity by incorporating tints, tones, and shades to extend the palette and make it more palatable for a wide range of projects.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fu45y1kcijjwzfziswhwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fu45y1kcijjwzfziswhwd.png" alt="complimentary colors visual" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://cdn.sanity.io/images/r115idoc/production/03449921b135f3f31854f957e68055563b17a2b1-1024x1024.webp?w=1080&amp;amp;q=75&amp;amp;fit=clip&amp;amp;auto=format" rel="noopener noreferrer"&gt;Clay&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Monochromatic&lt;/strong&gt;: A monochromatic color scheme involves using different shades, tints, and tones of one color. By adding touches of white, gray, or black, a single color can be expanded into a comprehensive color palette. It is extremely versatile, harmonious, and easy on the eye.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Feenbt5xq936so0zf43us.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Feenbt5xq936so0zf43us.png" alt="monochromatic color example" width="400" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://www.colorhunt.co/palette/3674b5578fcaa1e3f9d1f8ef" rel="noopener noreferrer"&gt;ColorHunt&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Analogous&lt;/strong&gt;: An analogous color scheme is created with three colors that are side by side. It starts with a base hue and is extended using two neighboring colors. The combination of these hues has a harmonious appeal, making it the perfect scheme for a soothing and serene vibe. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxreut00rbr8moqvhdnna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxreut00rbr8moqvhdnna.png" alt="analogous colors visual" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://www.figma.com/dictionary/analogous-colors/" rel="noopener noreferrer"&gt;Figma&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Triadic&lt;/strong&gt;: A triadic color scheme uses three colors that are evenly spaced around the color wheel. This provides a high contrast color scheme, but less so than the complementary color scheme, making it more versatile. Most triadic palettes are vibrant, contrasting, and can be difficult to balance. A good place to start is to assign one base hue, then use the remaining two hues as accent colors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fydgda1e3au3eju8oh95n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fydgda1e3au3eju8oh95n.png" alt="Triadic colors visual" width="800" height="460"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://www.canva.com/colors/color-wheel/" rel="noopener noreferrer"&gt;Canva&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tetradic&lt;/strong&gt;: A tetradic color scheme uses four colors that are evenly spaced on the color wheel. This scheme works best when you let one color be dominant and use the rest as accents. It’s good for when you want variety but still need harmony in your design.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F14y2kjn3sf686ju6hg9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F14y2kjn3sf686ju6hg9l.png" alt="Tetradic colors visual" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://international.binus.ac.id/graphic-design/2021/07/09/the-power-of-color/" rel="noopener noreferrer"&gt;Binus&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Color Psychology
&lt;/h4&gt;

&lt;p&gt;Color psychology involves examining the influence of colors on people's behaviors and moods. Different colors often evoke different emotions in the person perceiving them. To create a great design, you have to know what different colors mean and the emotional effect they have on users. &lt;/p&gt;

&lt;p&gt;Blue often signifies trustworthiness, serenity, and reliability. For that reason, it is a perfect choice for brands looking to depict professionalism and dependability. Companies like Facebook and LinkedIn use different shades of blue in their logos to develop user trust.&lt;/p&gt;

&lt;p&gt;On the other hand, red is known for being energetic, passionate, and attention-grabbing. This is a typical color used by brands that want an optimistic or demanding feel, like Netflix.&lt;/p&gt;

&lt;p&gt;Yellow stands for joyfulness, positivity, and warmth. However, its brightness can be overpowering if overused, so it's typically used for highlights and accents.&lt;/p&gt;

&lt;p&gt;Green signifies nature, growth, and harmony. It also signifies growth and prosperity, making it suitable for finance-related websites.&lt;/p&gt;

&lt;p&gt;Lastly, purple symbolizes luxury, creativity, royalty, or nobility. It is often used in beauty, luxury, and innovative technology websites to provide a sophisticated and unique feel.&lt;/p&gt;

&lt;p&gt;It is also nice to remember that a user's perception of color is dependent on factors such as their age, gender, culture, and religious beliefs. Colors can have many meanings that resonate differently with each user. Therefore, it is crucial to have your target audience in mind when choosing color palettes for web design.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Color Properties
&lt;/h4&gt;

&lt;p&gt;Color properties are the fundamental characteristics that define and distinguish one color from another. In web design and color theory, the main properties of color are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hue&lt;/strong&gt;: Hue refers to the basic color family or the name of the color itself, such as red, blue, yellow, or green. It is what most people think of as "color" and is determined by the wavelength of light&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Saturation&lt;/strong&gt;: Saturation (also called intensity or chroma) describes the purity or vividness of a color. Highly saturated colors are bold and vibrant, while low-saturation colors appear muted, grayish, or washed out. Saturation affects the mood and energy of a design, with high saturation often used for excitement and low saturation for calmness or sophistication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;: Value (sometimes called brightness or lightness) indicates how light or dark a color is, ranging from pure white to pure black. High-value colors are lighter, while low-value colors are darker. Value is crucial for creating contrast, depth, and visual hierarchy in web design&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Temperature&lt;/strong&gt;: Color temperature refers to whether a color feels warm (reds, oranges, yellows) or cool (blues, greens, purples). Warm colors evoke energy and passion, while cool colors are calming and serene. Temperature helps set the emotional tone and balance of a website.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Tools for creating color schemes and palettes
&lt;/h4&gt;

&lt;p&gt;There is a wide range of tools available to help you generate, refine, and experiment with color schemes and palettes. Most of these tools apply color theory principles, offer palette previews, as well as features for accessibility and export. &lt;br&gt;
Here are some of the most popular and effective options out there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://coolors.co/" rel="noopener noreferrer"&gt;Coolors&lt;/a&gt;&lt;/strong&gt; : A fast and user-friendly color palette generator. It also lets you extract color schemes from images.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://colormind.io" rel="noopener noreferrer"&gt;Colormind&lt;/a&gt;: A palette generator that leverages AI and deep learning to generate harmonious palettes, even from images or popular media.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://color.adobe.com/" rel="noopener noreferrer"&gt;Adobe Color&lt;/a&gt;&lt;/strong&gt; : A comprehensive palette generator based on color theory. It features a color wheel, a palette from image extraction, and an online library to explore trending color schemes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://paletton.com/" rel="noopener noreferrer"&gt;Paletton&lt;/a&gt;: A robust tool for creating color schemes based on color theory. It provides you with a color wheel, preview modes, harmony rules, and an accessibility simulation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.colorhunt.co/" rel="noopener noreferrer"&gt;ColorHunt&lt;/a&gt;: This is a community-driven platform for finding inspiration and trendy, curated palettes or generating new ones from a base color.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Responsive web design
&lt;/h3&gt;

&lt;p&gt;Responsive web design is an approach that ensures web pages render well and function optimally across a wide range of devices and screen sizes, from desktop monitors to tablets and smartphones. &lt;/p&gt;

&lt;p&gt;Coined by web designer and developer Ethan Marcotte in 2010, the primary goal of responsive web design is to provide users with a seamless and user-friendly experience, regardless of the device used to access the website.&lt;/p&gt;

&lt;p&gt;To create adaptable and flexible responsive web designs, below are some of the core principles and techniques you can apply:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Fluid Grids
&lt;/h4&gt;

&lt;p&gt;Fluid grids use relative units like percentages or viewport widths(vw) instead of fixed units like pixels. This allows layouts to scale proportionally to the screen size. &lt;br&gt;
For example, a two-column layout might use &lt;code&gt;width:50%&lt;/code&gt; for each column, ensuring they resize smoothly across devices.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Flexible images
&lt;/h4&gt;

&lt;p&gt;In a responsive design, images should scale within their containers to prevent overflow or distortion. One way to achieve this is by setting &lt;code&gt;max-width: 100%&lt;/code&gt; in CSS for media elements to ensure they scale down within their containing element.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Media queries
&lt;/h4&gt;

&lt;p&gt;Media queries are the backbone of responsive web design. They allow you to apply different styles at different screen widths by leveraging breakpoints. Breakpoints define where a layout changes based on screen size. Common breakpoints align with standard device widths (e.g., 576px for mobile, 768px for tablets, 992px for desktops). This means that by using media queries, your design adapts to fit various devices.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Mobile-first approach
&lt;/h4&gt;

&lt;p&gt;A mobile-first approach means designing for smaller screens first, then progressively enhancing the features to suit larger layouts as well. This strategy often leads to cleaner, more focused designs and better performance on mobile devices.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. The Viewport Meta Tag
&lt;/h4&gt;

&lt;p&gt;The viewport meta tag (&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;&lt;/code&gt;) tells the browser how to control the page's dimensions and scaling, ensuring your responsive design is rendered correctly on mobile devices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cultivate a design mindset
&lt;/h2&gt;

&lt;p&gt;A design mindset is a human-centered approach to problem-solving that emphasizes empathy, experimentation, and iterative progress. &lt;br&gt;
In the context of web design, it involves a way of thinking that prioritizes understanding user needs and continuously seeking innovative solutions to create intuitive, aesthetically pleasing, and functional websites.&lt;/p&gt;

&lt;p&gt;It emphasizes building user-driven solutions that genuinely resonate with target audiences. This requires you to shift from thinking primarily about technology and features to considering the user's perspective, emotions, and goals when interacting with an application.&lt;/p&gt;

&lt;p&gt;You can cultivate a design mindset by adopting practices that bridge technical expertise with design principles. Here are actionable steps to achieve this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Develop user empathy
&lt;/h3&gt;

&lt;p&gt;Try to engage directly with users through interviews, surveys, and observations to understand their needs and pain points. This firsthand exposure to users helps to align development decisions with user expectations and wants.&lt;br&gt;
Learning user experience(UX) basics, such as user personas and journey mapping, is also a good starting point for gaining more insight into user perspectives and how to design more inclusive web applications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Shift from Technology-First to Problem-First thinking
&lt;/h3&gt;

&lt;p&gt;Instead of starting each project or feature with technical specifications, try to start with user-focused questions. For example, "How might we make the sign-up process much easier for users?" rather than "How can we implement this authentication module?"&lt;br&gt;
Also, instead of measuring success by technical achievements, evaluate projects based on user satisfaction and goal completion. This shift helps prioritize features that genuinely add value for users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Embrace prototyping early and often
&lt;/h3&gt;

&lt;p&gt;Before investing in full development, try to create low-fidelity prototypes to test your ideas quickly. Observe how users interact with these prototypes and gather feedback to inform design decisions. This will help you design and develop programs that are user-oriented from the start.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Develop visual design awareness
&lt;/h3&gt;

&lt;p&gt;Spend time browsing design showcase sites like &lt;a href="https://dribbble.com/" rel="noopener noreferrer"&gt;Dribbble&lt;/a&gt; and &lt;a href=""&gt;Awwwards&lt;/a&gt; to develop an eye for effective interface design. You can also use these sites as a reference point for your designs. Learning and understanding the design fundamentals we covered earlier is also an effective way to develop this type of awareness.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Build cross-functional collaboration skills
&lt;/h3&gt;

&lt;p&gt;If you have the privilege of being in a team with UX/UI designers, try to work closely with them and not only understand their process but also contribute your technical insights during the design phase. This collaboration will grow your insight on how to design interfaces that are both user-friendly and technically feasible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h3&gt;
  
  
  Curiosity and Inspiration
&lt;/h3&gt;

&lt;p&gt;Foster curiosity by keeping your mind on the lookout for interesting design solutions in your daily life, from cafe menus to app interfaces. Or explore award-winning websites on Awwwards, Dribbble, or Behance. Doing this will keep you motivated and spark more creative ideas for your designs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Leverage design tools and software
&lt;/h2&gt;

&lt;p&gt;A more practical way to get better at design is to integrate design tools and software into your development workflow. Before jumping into code, use design tools to create wireframes, mockups, and prototypes that help you visualize your end product. This upfront investment saves significant development time by identifying potential issues early and establishing clear visual requirements.&lt;br&gt;
This approach will also help you directly apply most of the design principles we covered earlier. &lt;br&gt;
Some popular design tools you can use are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Figma&lt;/strong&gt;: A cloud-based design tool known for its real-time collaboration and robust prototyping capabilities. It’s widely used for UI/UX design and is accessible on any platform via a web browser, making it ideal for cross-functional teams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sketch&lt;/strong&gt;: Sketch is a Mac-exclusive design tool renowned for its vector editing capabilities and extensive plugin ecosystem. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Framer&lt;/strong&gt;: A powerful prototyping and design tool that combines visual design with code-based interactivity, ideal for developers comfortable with React or JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;InVision&lt;/strong&gt;: A prototyping and collaboration tool focused on creating interactive mockups and facilitating design feedback.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;In this comprehensive guide, we have covered basic guidelines on how to develop your design skills as a developer. &lt;br&gt;
We've delved into the key web design principles: visual design, typography, color theory, and responsive design. We've also looked at each principle in depth, from how to apply contrast, pick fonts, choose colors, to how to keep our designs adaptive and flexible. &lt;br&gt;
We've also learnt how to cultivate a design mindset by looking into practices that bridge technical expertise with design principles. &lt;br&gt;
Lastly, we've gone through how to incorporate modern design tools into your dev workflow. All of these guidelines will help you create more polished, user-centered applications while developing valuable design skills that are increasingly essential in modern development roles.&lt;br&gt;
In conclusion, I hope this blog helps you level up your design skills as a developer. Happy coding!&lt;/p&gt;

</description>
      <category>design</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>TypeScript FullStack project - BookVerse</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Mon, 23 Jun 2025 09:14:45 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/typescript-fullstack-project-bookverse-3i19</link>
      <guid>https://dev.to/muchai_joseph/typescript-fullstack-project-bookverse-3i19</guid>
      <description>&lt;p&gt;I recently built my first full-stack TypeScript project, blending modern web development with AI-powered features to redefine the digital reading experience!&lt;/p&gt;

&lt;p&gt;What is BookVerse?&lt;br&gt;
BookVerse is a web app that acts as your digital bookshelf. It lets you search for books, manage your book lists(favorites, reading lists, completed), access instant download links (Consumet API), and engage with an AI-powered chatbot for book summaries, insights, and recommendations. &lt;/p&gt;

&lt;p&gt;Check out the live preview: &lt;a href="https://bookvs.pages.dev/" rel="noopener noreferrer"&gt;https://bookvs.pages.dev/&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Tech Stack
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Frontend: React, TypeScript&lt;/li&gt;
&lt;li&gt;Backend: Express, Node, TypeScript&lt;/li&gt;
&lt;li&gt;Styling: Tailwind CSS&lt;/li&gt;
&lt;li&gt;APIs: Google Books API (for books and metadata), Consumet API for download links, and the new Google GEN-AI SDK for the chatbot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This project was a challenging yet rewarding journey into modern web development, streaming AI interactions with Server-Sent Events, and advanced API integrations. I’m excited to keep pushing the boundaries of what’s possible!&lt;/p&gt;

&lt;p&gt;Curious? Explore the code:&lt;br&gt;
Frontend: &lt;a href="https://github.com/Joseph-kdev/BookVerse" rel="noopener noreferrer"&gt;https://github.com/Joseph-kdev/BookVerse&lt;/a&gt;&lt;br&gt;
Backend: &lt;a href="https://github.com/Joseph-kdev/bookverse-server" rel="noopener noreferrer"&gt;https://github.com/Joseph-kdev/bookverse-server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts or feedback! What’s a feature you’d add to a digital bookshelf? Or how would you build it?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Getting started with Shadcn/UI in React: A practical guide</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Mon, 09 Sep 2024 08:01:12 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/getting-started-with-shadcnui-in-react-a-practical-guide-3kmj</link>
      <guid>https://dev.to/muchai_joseph/getting-started-with-shadcnui-in-react-a-practical-guide-3kmj</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The front-end development world is ever-changing. Front-end developers seek new ways to create high-quality, accessible, visually appealing user interfaces for websites and apps. This drives &lt;a href="https://react.dev/" rel="noopener noreferrer"&gt;React&lt;/a&gt; developers to constantly search for tools and libraries that can simplify their development process and help them create amazing user interfaces. This is where &lt;a href="https://ui.shadcn.com/" rel="noopener noreferrer"&gt;Shadcn/UI&lt;/a&gt; comes in.&lt;/p&gt;

&lt;p&gt;It is a collection of beautifully designed user interface (UI) components that you can easily copy and paste into your applications. Developers can use it with any framework that supports React, like &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next&lt;/a&gt;, &lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt;, &lt;a href="https://remix.run/" rel="noopener noreferrer"&gt;Remix&lt;/a&gt;, and others.&lt;/p&gt;

&lt;p&gt;In this practical guide, let us explore some of its key features, how to get started, and implement some hands-on examples. To fully understand the contents of this guide, you should have a good understanding of React and &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is Shadcn/UI?
&lt;/h3&gt;

&lt;p&gt;It is an open-source UI library that offers a comprehensive list of reusable front-end components designed for modern React applications. It takes a distinctly different approach from the more opinionated UI libraries like &lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;Material UI (MUI)&lt;/a&gt; or &lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;. While those libraries often have rigid, predefined styles and components, Shadcn/UI aggressively focuses on minimalism, accessibility, and customizability.&lt;/p&gt;

&lt;p&gt;It is not distributed via the &lt;a href="https://www.npmjs.com" rel="noopener noreferrer"&gt;node package manager (npm)&lt;/a&gt; as a dependency. Most UI libraries (such as MUI, Bootstrap, &lt;a href="https://chakra-ui.com/" rel="noopener noreferrer"&gt;Chakra UI&lt;/a&gt;, etc.), are distributed as npm packages which means you install them using &lt;code&gt;npm install "library-name"&lt;/code&gt;, and then you get all of the library UI components added to your code in the &lt;code&gt;node_modules&lt;/code&gt; as dependencies.&lt;/p&gt;

&lt;p&gt;However, for Shadcn/UI, developers run commands on the &lt;a href="https://www.npmjs.com/package/shadcn-ui" rel="noopener noreferrer"&gt;shadcn command line interface(&lt;code&gt;shadcn-cli&lt;/code&gt;)&lt;/a&gt; to selectively add components directly into their project. The &lt;code&gt;npx&lt;/code&gt; command, which allows running a package without needing to install the package globally, is used. For example, &lt;code&gt;npx shadcn-ui@latest add button&lt;/code&gt; fetches the latest &lt;code&gt;shadcn-cli&lt;/code&gt; version and runs the command to copy a button component's code directly into your project, not the &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This approach allows you to selectively integrate only the necessary components, providing greater flexibility and customization. When developers package components in an &lt;code&gt;npm&lt;/code&gt; package, they couple the style with the implementation, resulting in less customizable code.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To clarify, running &lt;code&gt;npm install shadcn-ui&lt;/code&gt; installs the &lt;code&gt;shadcn-cli&lt;/code&gt; and not the actual UI library. This is unnecessary since you can execute the &lt;code&gt;shadcn-cli&lt;/code&gt; using &lt;code&gt;npx&lt;/code&gt; without installing it globally.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is built with Tailwind in its foundation and incorporates components and techniques from the &lt;a href="https://www.radix-ui.com/" rel="noopener noreferrer"&gt;Radix UI&lt;/a&gt;. This combination of Tailwind and Radix UI allows for a unique blend of design flexibility, accessibility, and development speed. Developers can leverage the utility-first classes provided by Tailwind to style their components quickly.&lt;/p&gt;


&lt;h3&gt;
  
  
  Why use Shadcn/UI?
&lt;/h3&gt;

&lt;p&gt;Using it in your React projects offers several key benefits. Let's explore each one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: The components adhere to the &lt;a href="https://www.w3.org/TR/WCAG21/" rel="noopener noreferrer"&gt;Web Content Accessibility Guidelines (WCAG)&lt;/a&gt;, and provide keyboard navigation, screen reader support, and other accessibility features out of the box.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customizability&lt;/strong&gt;:  Developers can tailor the look and feel of each component to ensure it harmonizes with their application's overall design language. By decoupling component design from implementation, you get easier updates, scalability, and style swapping without affecting core functionality.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modularity&lt;/strong&gt;: Developers can select specific components to copy and paste directly into their projects. This approach promotes modularity and maintainability, making developers update, scale, and style components more easily.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of use&lt;/strong&gt;: Components offer a simple copy-paste approach that empowers developers with ownership and granular control over the codebase. Developers can now shape and style the components according to their unique preferences and requirements.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Utility-first design&lt;/strong&gt;: By leveraging Tailwind, there is a utility-first design approach, allowing you to apply styles and customize the appearance of your components quickly. Hence, faster development times and a more streamlined design process, as you don't write as much custom CSS.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ui.shadcn.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Amazing documentation&lt;/strong&gt;&lt;/a&gt;: The documentation is great, with clear explanations, code examples, and guidelines for using the library effectively.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Now, let us cover how to set up Shadcn/UI in a React project using &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt; without &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;Typescript&lt;/a&gt;. You can check out the &lt;a href="https://ui.shadcn.com/docs/installation" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; for more instructions on integrating with other frameworks.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use your terminal or command line interface to create a new React project.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest my-shadcn-app -- --template react
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;A new directory called &lt;code&gt;my-shadcn-app&lt;/code&gt; is created with a basic React project structure.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add Tailwind.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After navigating to the &lt;code&gt;my-shadcn-app&lt;/code&gt; project with your IDE, in the terminal run the commands below to install Tailwind and its peer dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -D tailwindcss postcss autoprefixer
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This will generate the&lt;code&gt;tailwind.config.js&lt;/code&gt; and &lt;code&gt;postcss.config.js&lt;/code&gt; files.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwindcss init -p
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create and edit a &lt;code&gt;jsconfig.json&lt;/code&gt; file:&lt;/strong&gt; Since we are not using &lt;code&gt;typescript&lt;/code&gt; we do not have a &lt;code&gt;tsconfig.json&lt;/code&gt; file like in the &lt;a href="https://ui.shadcn.com/docs/installation/vite" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. Hence, create a &lt;code&gt;jsconfig.json&lt;/code&gt; file. In this file, add the following code to tell the JavaScript language service to map the&lt;code&gt;@&lt;/code&gt; symbol to the &lt;code&gt;./src/&lt;/code&gt; directory, allowing you to use the &lt;code&gt;@&lt;/code&gt; symbol when importing components or modules from your project's &lt;code&gt;src&lt;/code&gt; directory:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fuugpriuhklbclqxqg1ts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fuugpriuhklbclqxqg1ts.png" alt="jsconfig code block" width="702" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Update &lt;code&gt;vite.config.js&lt;/code&gt;:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;First, install one more required dependency:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D @types/node
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Add the following configuration to ensure that &lt;code&gt;Vite&lt;/code&gt; can resolve the paths using the &lt;code&gt;@&lt;/code&gt; symbol in your imports:&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&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;path&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;path&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;react&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@vitejs/plugin-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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&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="s2"&gt;vite&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;react&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src&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="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add Shadcn/UI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install dependencies and set up the necessary files and structure for you to start using the reusable components, run:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest init
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The terminal will then prompt you for additional configurations. A preview of my responses:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fdybv8q7m5u4wyo6fnu4r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fdybv8q7m5u4wyo6fnu4r.png" alt="preview of terminal responses" width="538" height="302"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add a component&lt;/strong&gt;: You can create a component by copying its code from the specified documentation or adding it through the terminal.&lt;/p&gt;

&lt;p&gt;As an illustration, let us install a &lt;a href="https://ui.shadcn.com/docs/components/button" rel="noopener noreferrer"&gt;button&lt;/a&gt; component using the terminal. This component's code will be in the components folder after installation. It will provide everything you need to create your &lt;code&gt;Button&lt;/code&gt; component template. &lt;br&gt;
Run the command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add button
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The result:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4s95a883dhp42x7nq7xr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4s95a883dhp42x7nq7xr.png" alt="button component code" width="800" height="434"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;p&gt;To use the &lt;code&gt;Button&lt;/code&gt; component in your code import it like any other regular React component. You can customize its appearance by passing in the &lt;code&gt;variant&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; props.&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&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="s2"&gt;./components/ui/button&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;App&lt;/span&gt;&lt;span class="p"&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;Button&lt;/span&gt; &lt;span class="nx"&gt;variant&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ghost&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;Click&lt;/span&gt; &lt;span class="nx"&gt;me&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;/&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;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  More on themes and the theme editor
&lt;/h3&gt;

&lt;p&gt;Shadcn/UI offers a unique approach to theming by providing hand-picked themes that developers can copy and paste into their applications. You can customize these themes manually in your code by tweaking the default variables or using the &lt;a href="https://ui.shadcn.com/themes" rel="noopener noreferrer"&gt;theme editor online&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The online theme editor is more developer-friendly and provides a visual interface for configuring the style, color, &lt;code&gt;border-radius&lt;/code&gt;, and mode (light/dark). A preview of the theme editor:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9thCeGHB0js"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  Sample implementations with real-world UI examples
&lt;/h2&gt;

&lt;p&gt;Now, we will dive into some real-world UI scenarios to explore the components:&lt;/p&gt;

&lt;h3&gt;
  
  
  Carousel and Card: A simple product gallery
&lt;/h3&gt;

&lt;p&gt;A common UI element used in e-commerce websites is the carousel or image slider, which allows customers to preview product images. In this section, we will build a 'trending products' section for an online sneaker store.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/carousel" rel="noopener noreferrer"&gt;Carousel&lt;/a&gt; component from Shadcn/UI is built using the &lt;a href="https://www.embla-carousel.com" rel="noopener noreferrer"&gt;Embla carousel library&lt;/a&gt;. We will use this and the &lt;a href="https://ui.shadcn.com/docs/components/card" rel="noopener noreferrer"&gt;Card&lt;/a&gt; component to create a smooth and responsive image slider for product showcasing. &lt;/p&gt;

&lt;p&gt;To begin, add the &lt;code&gt;Carousel&lt;/code&gt; and &lt;code&gt;Card&lt;/code&gt; components to your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add card
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add carousel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, import these components from &lt;code&gt;@/components/ui&lt;/code&gt;. The &lt;code&gt;Card&lt;/code&gt;, &lt;code&gt;CardContent&lt;/code&gt;, and &lt;code&gt;CardTitle&lt;/code&gt; will structure and style the individual product cards. For the scrollable and interactive product showcase, import the &lt;code&gt;Carousel&lt;/code&gt;, &lt;code&gt;CarouselContent&lt;/code&gt;, &lt;code&gt;CarouselItem&lt;/code&gt;, &lt;code&gt;CarouselNext&lt;/code&gt;, &lt;code&gt;CarouselPrevious&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="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&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="s2"&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CardContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CardTitle&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="s2"&gt;@/components/ui/card&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;Carousel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CarouselContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CarouselItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CarouselNext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CarouselPrevious&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;@/components/ui/carousel&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;App&lt;/code&gt; function in the &lt;code&gt;App.jsx&lt;/code&gt; is the main React component that will render the UI. The &lt;code&gt;products&lt;/code&gt; array initializes dummy product data, where each object represents a product with a &lt;code&gt;name&lt;/code&gt; and an &lt;code&gt;image&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;return&lt;/code&gt; statement place a &lt;code&gt;div&lt;/code&gt; container styled with Tailwind to center the content and provide padding and a &lt;code&gt;h1&lt;/code&gt; element displaying the title "Trending Products".&lt;br&gt;
The Carousel component wraps all the product items, setting constraints for its width at different screen sizes.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&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="nx"&gt;products&lt;/span&gt; &lt;span class="o"&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Air max 90 PREMIUM Curry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/Air-max.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Air Jordan 1 High OG&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/Air-1.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Puma RSX Pink&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/puma-rsx-pink.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Air Force 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/shoe.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nike SuperRep Go&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/super.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Air Jordan 12&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/jordan-12.jpg&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Puma RSX Pink&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/puma-rsx-pink.jpg&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="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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex flex-col items-center justify-center py-8&lt;/span&gt;&lt;span class="dl"&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;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-2xl font-bold mb-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Trending&lt;/span&gt; &lt;span class="nx"&gt;Products&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;/h1&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="nx"&gt;Carousel&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full max-w-[90%] md:max-w-[80%] lg:max-w-[80%]&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="c1"&gt;// Carousel content will go here...&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Carousel&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;/div&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;/&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;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within the &lt;code&gt;Carousel&lt;/code&gt; component wrap the entire image slider with the &lt;code&gt;CarouselContent&lt;/code&gt; component. The &lt;code&gt;products.map()&lt;/code&gt; method iterates over each product in the array, creating a &lt;code&gt;CarouselItem&lt;/code&gt; for each. The &lt;code&gt;key&lt;/code&gt; attribute will ensure that each item is uniquely identifiable. &lt;/p&gt;

&lt;p&gt;The Tailwind utility class &lt;code&gt;basis&lt;/code&gt; in the &lt;code&gt;CarouselItem&lt;/code&gt; sets the number of products shown at different screen sizes. Each product item in &lt;code&gt;CarouselItem&lt;/code&gt; will be wrapped in a &lt;code&gt;Card&lt;/code&gt; component containing the &lt;code&gt;img&lt;/code&gt; element to showcase the product image and a &lt;code&gt;CardContent&lt;/code&gt; component that overlays the image with the product name.&lt;br&gt;
Outside of the &lt;code&gt;CarouselContent&lt;/code&gt;, the &lt;code&gt;CarouselPrevious&lt;/code&gt; and &lt;code&gt;CarouselNext&lt;/code&gt; components are used to navigate through the carousel items.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Carousel&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full max-w-[90%] md:max-w-[80%] lg:max-w-[80%]&lt;/span&gt;&lt;span class="dl"&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;CarouselContent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="nx"&gt;CarouselItem&lt;/span&gt;
        &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sm:basis-1/1 md:basis-1/2 lg:basis-1/3&lt;/span&gt;&lt;span class="dl"&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;Card&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-full&lt;/span&gt;&lt;span class="dl"&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;relative h-[300px]&lt;/span&gt;&lt;span class="dl"&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;img&lt;/span&gt;
              &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
              &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
              &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-full w-full object-cover&lt;/span&gt;&lt;span class="dl"&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;CardContent&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute bottom-0 left-0 right-0 bg-white/70 p-4&lt;/span&gt;&lt;span class="dl"&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;CardTitle&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&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;/CardTitle&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;/CardContent&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;/div&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;/Card&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;/CarouselItem&lt;/span&gt;&lt;span class="err"&gt;&amp;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;/CarouselContent&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="nx"&gt;CarouselPrevious&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute left-2 top-1/2 -translate-y-1/2&lt;/span&gt;&lt;span class="dl"&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;CarouselNext&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute right-2 top-1/2 -translate-y-1/2&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/Carousel&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation creates a responsive product gallery with a carousel, displaying product images and names in a visually appealing manner:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wV8vLV1tFLw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Accordion: A Frequently Asked Questions(FAQ) section
&lt;/h3&gt;

&lt;p&gt;A Frequently Asked Questions (FAQ) page is an integral part of any SaaS (Software as a Service) platform. It addresses the user's most common questions, removing the need to search through extensive documentation for information. &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/accordion" rel="noopener noreferrer"&gt;accordion&lt;/a&gt; is a vertically stacked set of interactive headings that reveal a section of content. It is the perfect component for building a FAQ section or page. Here, we will implement a responsive FAQ page for an artificial intelligence SaaS platform.&lt;/p&gt;

&lt;p&gt;Start by installing the &lt;code&gt;Accordion&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add accordion
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The components &lt;code&gt;Accordion&lt;/code&gt;, &lt;code&gt;AccordionItem&lt;/code&gt;, &lt;code&gt;AccordionTrigger&lt;/code&gt;, and &lt;code&gt;AccordionContent&lt;/code&gt; will be imported from the &lt;code&gt;ui&lt;/code&gt; folder under &lt;code&gt;components&lt;/code&gt; and into the &lt;code&gt;App.jsx&lt;/code&gt;. These components will be essential for creating an accordion-style interface.&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;Accordion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;AccordionItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;AccordionTrigger&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;AccordionContent&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;@/components/ui/accordion&lt;/span&gt;&lt;span class="dl"&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 the &lt;code&gt;App&lt;/code&gt; function, initialize the &lt;code&gt;faqs&lt;/code&gt; array with a set of FAQ objects, each containing a question and an answer. This data structure will allow for easy iteration and dynamic rendering of each FAQ item. &lt;/p&gt;

&lt;p&gt;In the return statement, a &lt;code&gt;div&lt;/code&gt; container houses our entire implementation. Within this &lt;code&gt;div&lt;/code&gt; we will have a &lt;code&gt;h2&lt;/code&gt; element displaying the title "Frequently Asked Questions," centered and styled for emphasis. Another &lt;code&gt;div&lt;/code&gt; will be used to wrap around the actual &lt;code&gt;Accordion&lt;/code&gt; component.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&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="nx"&gt;faqs&lt;/span&gt; &lt;span class="o"&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;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;How does your AI SaaS platform work?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Our AI SaaS platform leverages advanced machine learning algorithms to provide intelligent solutions for our customers. Users can access a wide range of features and tools to enhance their workflows and decision-making processes.&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="na"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What kind of AI models does the platform support?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The platform supports a variety of AI models, including natural language processing, computer vision, and predictive analytics. We are constantly expanding our AI capabilities to meet the evolving needs of our customers.&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="na"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;How secure is the data on your platform?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Data security and privacy are our top priorities. We employ industry-leading encryption and access controls to ensure the confidentiality and integrity of our customer's data. Our platform is regularly audited and certified to meet the highest security standards.&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="na"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Do you offer any integration options?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Yes, our AI SaaS platform integrates seamlessly with several business software and tools, including CRM, ERP, and project management systems. This allows our customers to incorporate the AI into their existing workflows.&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="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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;max-w-5xl mx-auto py-12&lt;/span&gt;&lt;span class="dl"&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;h2&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-3xl font-bold mb-8 text-center mb-10&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Frequently&lt;/span&gt; &lt;span class="nx"&gt;Asked&lt;/span&gt; &lt;span class="nx"&gt;Questions&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;/h2&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="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;md:flex gap-2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;// image and accordion component will be here...&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&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;/div&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;/&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;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;div&lt;/code&gt; that will wrap around the &lt;code&gt;Accordion&lt;/code&gt; component, initialize two &lt;code&gt;divs&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;The first &lt;code&gt;div&lt;/code&gt; will have an image element visible only on medium and larger screens (&lt;code&gt;md:block&lt;/code&gt;). The image will be aligned to take half the available width (&lt;code&gt;md:w-1/2&lt;/code&gt;), providing a visual complement to the FAQs.&lt;/p&gt;

&lt;p&gt;The second &lt;code&gt;div&lt;/code&gt; will also take half the width on medium and larger screens and contain the &lt;code&gt;Accordion&lt;/code&gt; component. The &lt;code&gt;Accordion&lt;/code&gt; component will be initialized with the &lt;code&gt;type="single"&lt;/code&gt; and &lt;code&gt;collapsible&lt;/code&gt; props, meaning only one accordion item can be open at a time, and the user can collapse the open item. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;faqs.map()&lt;/code&gt; method iterates through the array of FAQ objects, generating an &lt;code&gt;AccordionItem&lt;/code&gt; for each. Inside each &lt;code&gt;AccordionItem&lt;/code&gt;, the &lt;code&gt;AccordionTrigger&lt;/code&gt; will display the question (&lt;code&gt;faq.question&lt;/code&gt;) as a clickable heading (&lt;code&gt;h3&lt;/code&gt;). The &lt;code&gt;AccordionContent&lt;/code&gt; reveals the corresponding answer (&lt;code&gt;faq.answer&lt;/code&gt;) when the item is expanded.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;md:flex gap-2&lt;/span&gt;&lt;span class="dl"&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;md:w-1/2 hidden md:block h-8 m-9&lt;/span&gt;&lt;span class="dl"&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;img&lt;/span&gt;
      &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/src/assets/artAI.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AI Assistant&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-64 h-auto&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;md:w-1/2&lt;/span&gt;&lt;span class="dl"&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;Accordion&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;single&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;collapsible&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;faqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="nx"&gt;AccordionItem&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`item-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&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;AccordionTrigger&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;h3&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-lg font-medium&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;question&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;/h3&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;/AccordionTrigger&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="nx"&gt;AccordionContent&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;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&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;/p&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;/AccordionContent&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;/AccordionItem&lt;/span&gt;&lt;span class="err"&gt;&amp;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;/Accordion&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;/div&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;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, export the &lt;code&gt;App&lt;/code&gt; component as the default export:&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The outcome is a clean and organized FAQ section which users can easily interact with:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fotncb5yc9ui41sx6n1xe.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fotncb5yc9ui41sx6n1xe.jpeg" alt="FAQ page preview" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aspect ratio: Responsive YouTube Video Embed
&lt;/h3&gt;

&lt;p&gt;Embedding YouTube videos is common in many web applications, especially content-driven ones like blogs, tutorials, or educational platforms. Implementing video embeds in React applications can sometimes be a pain since you apply extra &lt;code&gt;CSS&lt;/code&gt; styles to achieve responsiveness.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/aspect-ratio" rel="noopener noreferrer"&gt;AspectRatio&lt;/a&gt; component allows us to create consistent and visually appealing display layouts. You can use it with images or videos. In this section, we implement a simple blog that embeds a YouTube video.&lt;/p&gt;

&lt;p&gt;First, add the &lt;code&gt;AspectRatio&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add aspect-ratio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, import the &lt;code&gt;AspectRatio&lt;/code&gt; component from our project's UI components directory. This component will help maintain a consistent aspect ratio for our embedded video.&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;AspectRatio&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="s2"&gt;./components/ui/aspect-ratio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, define a &lt;code&gt;VideoEmbed&lt;/code&gt; function component. This component will render a YouTube video embedded within an &lt;code&gt;AspectRatio&lt;/code&gt; wrapper to maintain a 16:9 aspect ratio. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;iframe&lt;/code&gt; element within the &lt;code&gt;AspectRatio&lt;/code&gt; component will embed the YouTube video. Set various attributes on the &lt;code&gt;iframe&lt;/code&gt; to control its behavior and appearance, including the video source, title, and allowed features.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;VideoEmbed&lt;/span&gt;&lt;span class="p"&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;&lt;/span&gt;&lt;span class="nx"&gt;AspectRatio&lt;/span&gt; &lt;span class="nx"&gt;ratio&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;9&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;iframe&lt;/span&gt;
        &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://www.youtube.com/embed/AqmMx_JidGo?si=1A9BJFdRBaq5axwv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YouTube video player&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;frameBorder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;allowFullScreen&lt;/span&gt;
        &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full h-full&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/AspectRatio&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;The main &lt;code&gt;App&lt;/code&gt; function component will structure the layout of our page. Wrap the content in a &lt;code&gt;div&lt;/code&gt; container with Tailwind CSS classes to set maximum width, center the content, and add padding. Inside this container, place a &lt;code&gt;h1&lt;/code&gt; element for the main title, styled with Tailwind for size, weight, and margin, and a paragraph of lorem ipsum text above the video embed. Also, place the &lt;code&gt;VideoEmbed&lt;/code&gt; component defined earlier and a paragraph of text below the video embed.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;max-w-5xl mx-auto py-2 px-5&lt;/span&gt;&lt;span class="dl"&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;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-3xl font-bold mb-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt; &lt;span class="nx"&gt;glimpse&lt;/span&gt; &lt;span class="nx"&gt;into&lt;/span&gt; &lt;span class="nx"&gt;Shadcn&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;ui&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&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="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mb-8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Lorem&lt;/span&gt; &lt;span class="nx"&gt;ipsum&lt;/span&gt; &lt;span class="nx"&gt;dolor&lt;/span&gt; &lt;span class="nx"&gt;sit&lt;/span&gt; &lt;span class="nx"&gt;amet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;consectetur&lt;/span&gt; &lt;span class="nx"&gt;adipiscing&lt;/span&gt; &lt;span class="nx"&gt;elit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Donec&lt;/span&gt;
          &lt;span class="nx"&gt;suscipit&lt;/span&gt; &lt;span class="nx"&gt;semper&lt;/span&gt; &lt;span class="nx"&gt;neque&lt;/span&gt; &lt;span class="nx"&gt;sed&lt;/span&gt; &lt;span class="nx"&gt;imperdiet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Suspendisse&lt;/span&gt; &lt;span class="nx"&gt;ac&lt;/span&gt; &lt;span class="nx"&gt;urna&lt;/span&gt; &lt;span class="nx"&gt;luctus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;tincidunt&lt;/span&gt; &lt;span class="nx"&gt;mauris&lt;/span&gt; &lt;span class="nx"&gt;sit&lt;/span&gt; &lt;span class="nx"&gt;amet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fringilla&lt;/span&gt; &lt;span class="nx"&gt;enim&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Etiam&lt;/span&gt; &lt;span class="nx"&gt;quis&lt;/span&gt; &lt;span class="nx"&gt;neque&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;leo&lt;/span&gt;
          &lt;span class="nx"&gt;sollicitudin&lt;/span&gt; &lt;span class="nx"&gt;maximus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Aenean&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="nx"&gt;pulvinar&lt;/span&gt; &lt;span class="nx"&gt;elit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Morbi&lt;/span&gt; &lt;span class="nx"&gt;viverra&lt;/span&gt; &lt;span class="nx"&gt;quam&lt;/span&gt;
          &lt;span class="nx"&gt;tempor&lt;/span&gt; &lt;span class="nx"&gt;nunc&lt;/span&gt; &lt;span class="nx"&gt;sollicitudin&lt;/span&gt; &lt;span class="nx"&gt;fringilla&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Nullam&lt;/span&gt; &lt;span class="nx"&gt;malesuada&lt;/span&gt; &lt;span class="nx"&gt;vestibulum&lt;/span&gt;
          &lt;span class="nx"&gt;congue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Aliquam&lt;/span&gt; &lt;span class="nx"&gt;ac&lt;/span&gt; &lt;span class="nx"&gt;ante&lt;/span&gt; &lt;span class="nx"&gt;gravida&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dapibus&lt;/span&gt; &lt;span class="nx"&gt;ante&lt;/span&gt; &lt;span class="nx"&gt;nec&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;congue&lt;/span&gt; &lt;span class="nx"&gt;nisl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
          &lt;span class="nx"&gt;Maecenas&lt;/span&gt; &lt;span class="nx"&gt;orci&lt;/span&gt; &lt;span class="nx"&gt;purus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;porttitor&lt;/span&gt; &lt;span class="nx"&gt;non&lt;/span&gt; &lt;span class="nx"&gt;enim&lt;/span&gt; &lt;span class="nx"&gt;non&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ultrices&lt;/span&gt; &lt;span class="nx"&gt;faucibus&lt;/span&gt; &lt;span class="nx"&gt;est&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
          &lt;span class="nx"&gt;Nullam&lt;/span&gt; &lt;span class="nx"&gt;vitae&lt;/span&gt; &lt;span class="nx"&gt;odio&lt;/span&gt; &lt;span class="nx"&gt;fringilla&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;molestie&lt;/span&gt; &lt;span class="nx"&gt;ante&lt;/span&gt; &lt;span class="nx"&gt;ut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;luctus&lt;/span&gt; &lt;span class="nx"&gt;ante&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;/p&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="nx"&gt;VideoEmbed&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;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Neque&lt;/span&gt; &lt;span class="nx"&gt;porro&lt;/span&gt; &lt;span class="nx"&gt;quisquam&lt;/span&gt; &lt;span class="nx"&gt;est&lt;/span&gt; &lt;span class="nx"&gt;qui&lt;/span&gt; &lt;span class="nx"&gt;dolorem&lt;/span&gt; &lt;span class="nx"&gt;ipsum&lt;/span&gt; &lt;span class="nx"&gt;quia&lt;/span&gt; &lt;span class="nx"&gt;dolor&lt;/span&gt; &lt;span class="nx"&gt;sit&lt;/span&gt; &lt;span class="nx"&gt;amet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;consectetur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;adipisci&lt;/span&gt; &lt;span class="nx"&gt;velit&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;/p&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;/div&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;/&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;Finally, export the &lt;code&gt;App&lt;/code&gt; component as the default export:&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation creates a page with a title, introductory text, an embedded YouTube video maintained at a 16:9 aspect ratio, and a concluding text. The layout is responsive and centered on the page, providing a clean and organized content presentation.&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fgp10mc1e4gro7a1p0nx4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fgp10mc1e4gro7a1p0nx4.jpeg" alt="Blog page preview" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Command and Sheet: Collapsible sidebar
&lt;/h3&gt;

&lt;p&gt;A popular UI navigation pattern is the sidebar. For easier accessibility on smaller devices, it is made collapsible. We will implement it using the command and sheet components. &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/command" rel="noopener noreferrer"&gt;command&lt;/a&gt; component allows us to create a command menu for react that offers functionality like displaying suggestions, settings, and more in a command-like interface. It uses the &lt;code&gt;cmdk&lt;/code&gt; component, a combo box search, and command component. &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/sheet" rel="noopener noreferrer"&gt;sheet&lt;/a&gt; component extends the &lt;a href="https://ui.shadcn.com/docs/components/dialog" rel="noopener noreferrer"&gt;dialog&lt;/a&gt; component to display content that complements the main content of the screen from the &lt;a href="https://ui.shadcn.com/docs/components/sheet" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt;. It is a good option when building components that require user interaction, such as menus and modal dialogs.&lt;/p&gt;

&lt;p&gt;In our example, we will combine these 2 to build a &lt;code&gt;collapsible sidebar&lt;/code&gt; for a project management tool.&lt;/p&gt;

&lt;p&gt;First, install the needed components. Using the &lt;code&gt;npm&lt;/code&gt; command line interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add sheet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add command
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, import the necessary components from our project's UI components folder. These include the &lt;code&gt;Command&lt;/code&gt; components for creating a command palette interface, &lt;code&gt;Sheet&lt;/code&gt; components for a sliding panel, and the &lt;code&gt;Button&lt;/code&gt; component for our menu trigger. We will also import several icons from the &lt;code&gt;lucide-react&lt;/code&gt; library to enhance our UI.&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;Command&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandEmpty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandGroup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandInput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;CommandSeparator&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;@/components/ui/command&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;Sheet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SheetContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SheetDescription&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SheetHeader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SheetTitle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SheetTrigger&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;@/components/ui/sheet&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;Button&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="s2"&gt;./components/ui/button&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;BriefcaseIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;FolderClosedIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;LayoutDashboardIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;LogOutIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;MenuIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;ReceiptEuroIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;SettingsIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;UserIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;UsersIcon&lt;/span&gt;&lt;span class="p"&gt;,&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="s2"&gt;lucide-react&lt;/span&gt;&lt;span class="dl"&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 our &lt;code&gt;App&lt;/code&gt; function in &lt;code&gt;App.jsx&lt;/code&gt;, structure a sliding menu panel using the &lt;code&gt;Sheet&lt;/code&gt; component. The &lt;code&gt;SheetTrigger&lt;/code&gt; will contain a &lt;code&gt;Button&lt;/code&gt; component with a &lt;code&gt;MenuIcon&lt;/code&gt;, which will open the sliding panel when clicked.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;SheetContent&lt;/code&gt;, set up the structure of our sliding panel. Use &lt;code&gt;SheetHeader&lt;/code&gt; to display the user's name and role, followed by a &lt;code&gt;Command&lt;/code&gt; component to create an interactive command palette.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&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;Sheet&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;SheetTrigger&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;variant&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ghost&lt;/span&gt;&lt;span class="dl"&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;MenuIcon&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;menu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&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="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;/SheetTrigger&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="nx"&gt;SheetContent&lt;/span&gt; &lt;span class="nx"&gt;side&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;left&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-[370px]&lt;/span&gt;&lt;span class="dl"&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;SheetHeader&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;SheetTitle&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;John&lt;/span&gt; &lt;span class="nx"&gt;Doe&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SheetTitle&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="nx"&gt;SheetDescription&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Project&lt;/span&gt; &lt;span class="nx"&gt;Manager&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SheetDescription&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="nx"&gt;Command&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="c1"&gt;// Command input and list components will go here...&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Command&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;/SheetHeader&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;/SheetContent&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;/Sheet&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;/&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;Within the &lt;code&gt;Command&lt;/code&gt; component, add a &lt;code&gt;CommandInput&lt;/code&gt; for user searches, and a &lt;code&gt;CommandList&lt;/code&gt; to display various options. Use &lt;code&gt;CommandGroup&lt;/code&gt; components to organize our options into categories, and &lt;code&gt;CommandItem&lt;/code&gt; components for individual menu items. Each &lt;code&gt;CommandItem&lt;/code&gt; will contain an icon and a link.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Command&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;CommandInput&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Type a command or search...&lt;/span&gt;&lt;span class="dl"&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;CommandList&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;CommandEmpty&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;No&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="nx"&gt;found&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;/CommandEmpty&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="nx"&gt;CommandGroup&lt;/span&gt; &lt;span class="nx"&gt;heading&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Suggestions&lt;/span&gt;&lt;span class="dl"&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;CommandItem&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;LayoutDashboardIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Dashboard&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;BriefcaseIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Projects&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;FolderClosedIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Tasks&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;UsersIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Team&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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;/CommandGroup&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="nx"&gt;CommandSeparator&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;CommandGroup&lt;/span&gt; &lt;span class="nx"&gt;heading&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Settings&lt;/span&gt;&lt;span class="dl"&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;CommandItem&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;UserIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Profile&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;ReceiptEuroIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-6 w-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Billing&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;SettingsIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-6 h-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Settings&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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="nx"&gt;CommandItem&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;LogOutIcon&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-6 h-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &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="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Logout&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&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;/CommandItem&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;/CommandGroup&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;/CommandList&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;/Command&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To style the components, add custom theme tokens to the &lt;code&gt;index.css&lt;/code&gt; file. These tokens will define the background, accent, and accent foreground colors for our theme.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@layer&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;96.1%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--accent-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;47.4%&lt;/span&gt; &lt;span class="m"&gt;11.2%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation creates a sliding menu panel with a command palette interface, allowing users to navigate quickly through sections of the application. The panel is triggered by a menu button and slides in from the left side of the screen. The command palette provides a search input and categorized menu items, each with an associated icon for easy recognition.&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wYFa5l9hbok"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Dialog and Tabs: Sign-up/Sign-in pop-up
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/dialog" rel="noopener noreferrer"&gt;dialog&lt;/a&gt; component is a modal window that appears above the main app content to provide critical contextual information or ask for a decision. It can create interactive command menus, modal dialogs, and other UI elements that require user interaction.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ui.shadcn.com/docs/components/tabs" rel="noopener noreferrer"&gt;tabs&lt;/a&gt; component allows for the creation of tabbed navigation in a user interface. Tabbed navigation helps conserve screen real estate, which is particularly useful for mobile applications or websites where space is limited. &lt;/p&gt;

&lt;p&gt;We will use these components to create a Sign-up/Sign-in pop-up section.&lt;/p&gt;

&lt;p&gt;To begin, install the required components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add tabs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add dialog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add input
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx shadcn-ui@latest add label
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, import the necessary components. These include the &lt;code&gt;Button&lt;/code&gt;, &lt;code&gt;Dialog&lt;/code&gt;, &lt;code&gt;Input&lt;/code&gt;, &lt;code&gt;Label&lt;/code&gt;, and &lt;code&gt;Tabs&lt;/code&gt; components, along with their related subcomponents. These will create an interactive sign-up and sign-in form within a modal dialog.&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;Button&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="s2"&gt;./components/ui/button&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;Dialog&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DialogContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DialogTrigger&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="s2"&gt;@/components/ui/dialog&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;Input&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="s2"&gt;@/components/ui/input&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;Label&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="s2"&gt;@/components/ui/label&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;Tabs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;TabsContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;TabsList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;TabsTrigger&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="s2"&gt;@/components/ui/tabs&lt;/span&gt;&lt;span class="dl"&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 the &lt;code&gt;App&lt;/code&gt; function, structure a modal dialog using the &lt;code&gt;Dialog&lt;/code&gt; component. The &lt;code&gt;DialogTrigger&lt;/code&gt; will contain a &lt;code&gt;Button&lt;/code&gt; component with the text "Join in", which will open the modal when clicked. &lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;DialogContent&lt;/code&gt;, set up a tabbed interface using the &lt;code&gt;Tabs&lt;/code&gt; component. This will allow users to switch between sign-up and sign-in forms. The &lt;code&gt;defaultValue="Sign up"&lt;/code&gt; ensures that the "Sign up" tab is selected by default when the dialog opens. Use the &lt;code&gt;TabsList&lt;/code&gt; and &lt;code&gt;TabsTrigger&lt;/code&gt; components to create the tab navigation.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&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;Dialog&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;DialogTrigger&lt;/span&gt; &lt;span class="nx"&gt;asChild&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="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Join&lt;/span&gt; &lt;span class="k"&gt;in&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;/DialogTrigger&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="nx"&gt;DialogContent&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sm:max-w-[455px]&lt;/span&gt;&lt;span class="dl"&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;Tabs&lt;/span&gt; &lt;span class="nx"&gt;defaultValue&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sign up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-[400px]&lt;/span&gt;&lt;span class="dl"&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;TabsList&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;grid w-full grid-cols-2&lt;/span&gt;&lt;span class="dl"&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;TabsTrigger&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sign up&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;up&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/TabsTrigger&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="nx"&gt;TabsTrigger&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sign in&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/TabsTrigger&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;/TabsList&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="c1"&gt;// Tab content will go here...&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Tabs&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;/DialogContent&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;/Dialog&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;/&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;Within each &lt;code&gt;TabsContent&lt;/code&gt;, create form fields using the &lt;code&gt;Label&lt;/code&gt; and &lt;code&gt;Input&lt;/code&gt; components. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;TabsContent&lt;/code&gt; with &lt;code&gt;value="Sign up"&lt;/code&gt; contains the form fields for signing up, including inputs for the user's name, email, and password. Similarly, the &lt;code&gt;TabsContent&lt;/code&gt; with &lt;code&gt;value="Sign in"&lt;/code&gt; includes form fields for signing in, with inputs for the user's email and password.  Each form will end with a submit button.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TabsContent&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sign up&lt;/span&gt;&lt;span class="dl"&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;space-y-2&lt;/span&gt;&lt;span class="dl"&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;Label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Your&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Label&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="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Name&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;space-y-1&lt;/span&gt;&lt;span class="dl"&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;Label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Your&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Label&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="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Email&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;space-y-1&lt;/span&gt;&lt;span class="dl"&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;Label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Build&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Label&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="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full my-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;up&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;/TabsContent&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="nx"&gt;TabsContent&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sign in&lt;/span&gt;&lt;span class="dl"&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;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;space-y-2&lt;/span&gt;&lt;span class="dl"&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;Label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Your&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Label&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="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Email&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;space-y-1&lt;/span&gt;&lt;span class="dl"&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;Label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Remember&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Label&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="nx"&gt;Input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&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="sr"&gt;/div&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="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full my-4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="k"&gt;in&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;/TabsContent&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To style the component, add custom theme tokens to our &lt;code&gt;index.css&lt;/code&gt; file. These tokens will define various color and style properties for our theme, including background colors, text colors, border styles, and more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@layer&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;84%&lt;/span&gt; &lt;span class="m"&gt;4.9%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--card&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--card-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;84%&lt;/span&gt; &lt;span class="m"&gt;4.9%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--popover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--popover-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;84%&lt;/span&gt; &lt;span class="m"&gt;4.9%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;221.2&lt;/span&gt; &lt;span class="m"&gt;83.2%&lt;/span&gt; &lt;span class="m"&gt;53.3%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--primary-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;98%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--secondary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;96.1%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--secondary-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;47.4%&lt;/span&gt; &lt;span class="m"&gt;11.2%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--muted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;96.1%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--muted-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;215.4&lt;/span&gt; &lt;span class="m"&gt;16.3%&lt;/span&gt; &lt;span class="m"&gt;46.9%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;96.1%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--accent-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;222.2&lt;/span&gt; &lt;span class="m"&gt;47.4%&lt;/span&gt; &lt;span class="m"&gt;11.2%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--destructive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;84.2%&lt;/span&gt; &lt;span class="m"&gt;60.2%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--destructive-foreground&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt; &lt;span class="m"&gt;98%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;214.3&lt;/span&gt; &lt;span class="m"&gt;31.8%&lt;/span&gt; &lt;span class="m"&gt;91.4%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;214.3&lt;/span&gt; &lt;span class="m"&gt;31.8%&lt;/span&gt; &lt;span class="m"&gt;91.4%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--ring&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;221.2&lt;/span&gt; &lt;span class="m"&gt;83.2%&lt;/span&gt; &lt;span class="m"&gt;53.3%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation creates an interactive modal dialog with tabbed sign-up and sign-in forms. The dialog is triggered by a "Join in" button. The forms are styled consistently with the custom theme, providing a cohesive and visually appealing user interface. The tabs allow for a compact design that accommodates new and existing users within the same modal, improving the overall user experience.&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/kRYOxtN_AeU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;p&gt;Shadcn/UI ensures a streamlined development experience when working with React. However, for it to be as effective, there are some best practices developers should try to uphold. These include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance optimization&lt;/strong&gt;: Leverage the built-in performance optimizations provided, such as lazy loading and code splitting. Implement efficient state management within the components and use dynamic imports to load components on demand.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: Adhere to implementation conventions, such as component-based structures, to ensure consistency throughout your codebase. Document your custom components, to make it easier for other developers to understand and contribute to the codebase.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customization and extensibility&lt;/strong&gt;: Familiarize yourself with the various customization options provided, such as theme configuration and component override. Extend the existing components by creating custom variants or adding new functionality to suit your project's needs. While still adhering to the same design principles and accessibility standards.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;We have explored the Shadcn/UI library from what makes it stand out from other UI libraries/frameworks to why you should use it as a React developer. The reasons are the unrivaled focus on customizability, accessibility, modularity, ease of use, a utility-first design, and clear documentation.&lt;/p&gt;

&lt;p&gt;We have also demonstrated its versatility by building examples using some components. We have implemented a product gallery, a FAQ section, a responsive YouTube embed, a collapsible sidebar, and a sign-up/sign-in pop-up. The code for all the implementations can be found &lt;a href="https://github.com/Joseph-kdev/my-shadcn-app" rel="noopener noreferrer"&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly, we have looked at the best practices, such as optimizing the performance, ensuring maintainability, and carrying out customizations and extensions. All these ensure we leverage it to build robust, visually appealing, and accessible user interfaces.&lt;/p&gt;

&lt;p&gt;In conclusion, I hope this blog helps build a better understanding of the library. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Guide to Higher-Order Functions in JavaScript</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Tue, 02 Jul 2024 14:35:35 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/a-guide-to-higher-order-functions-in-javascript-2o3d</link>
      <guid>https://dev.to/muchai_joseph/a-guide-to-higher-order-functions-in-javascript-2o3d</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@growtika?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Growtika&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you work with JavaScript, then you might have encountered higher-order functions. This is not to mean that they are only limited to JavaScript alone. On the contrary higher-order functions are a fundamental aspect of functional programming that can be found in various programming languages.&lt;/p&gt;

&lt;p&gt;The ability to use higher-order functions is more linked with the language’s support for functional programming and the programming paradigm in play.&lt;/p&gt;

&lt;p&gt;In this article we’ll dig deeper into what higher-order functions are, their use case scenarios, benefits, and some common mistakes encountered while using them in JavaScript.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is a higher-order function?
&lt;/h3&gt;

&lt;p&gt;A higher-order function is a function that takes one or more functions as arguments or returns a function as its result.&lt;/p&gt;

&lt;p&gt;In that definition lies the key characteristics of identifying a higher-order function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Takes a function as an argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Returns a function.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This whole concept of higher-order functions in programming is borrowed from mathematics, specifically from the field of functional programming and lambda calculus (a little nerdy note 😁).&lt;/p&gt;

&lt;p&gt;In lambda calculus and mathematical logic, functions are considered first-class citizens, meaning they can be treated as values, passed as arguments to other functions, and returned as results from functions.&lt;/p&gt;

&lt;p&gt;For example, the derivative operator in calculus is a higher-order function that maps a function to its derivative, which is also a function. Similarly, in JavaScript, filter() is a higher-order function that works on an array and takes another function as an argument that it’ll use to return a new filtered version of the array.&lt;/p&gt;

&lt;p&gt;Now that we know what higher-order functions are, let’s move on to their applications:&lt;/p&gt;




&lt;h3&gt;
  
  
  Common Use Cases
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. Callback functions
&lt;/h3&gt;

&lt;p&gt;A callback function is simply a function that is passed as an argument to another function and is executed inside the outer function to complete some routine or action.&lt;/p&gt;

&lt;p&gt;This technique allows a function to call another function.&lt;/p&gt;

&lt;p&gt;Callback functions are commonly used in asynchronous programming to handle tasks that may take time to complete such as a network request or handling an event for example a button click or a timer expiration.&lt;/p&gt;

&lt;p&gt;Let’s implement a simple instance of callbacks in play within an asynchronous task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Asynchronous application of a callback function

function getDataFromServer(callback) {
  // Simulating a server request with a setTimeout
  setTimeout(function() {
    const data = 'Data from the server';
    callback(data);
  }, 2000);
}

// Callback function to handle the data
function displayData(data) {
  console.log('Data received: ' + data);
}

// Calling the function with the callback
getDataFromServer(displayData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In this example, we use the getDataFromServer function to simulate a server request using setTimeout and then call the callback function with the data after 2 seconds. The displayData function is the callback that handles the received data. When getDataFromServer is called with displayData as the callback, it logs the received data after 2 seconds.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This demonstrates the asynchronous nature of the callback, as the data is handled after the server request is complete.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Array Methods
&lt;/h3&gt;

&lt;p&gt;Array methods are functions that can be called on an array object to perform various operations on the array.&lt;/p&gt;

&lt;p&gt;They are quite a number but &lt;strong&gt;not all&lt;/strong&gt; of them are higher-order functions it should be noted. The higher-order array methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;forEach()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;map()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;sort()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;filter() and&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;reduce()&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s take a quick look at each:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. forEach()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is a higher-order function that iterates over each item of an array executing the function passed in as an argument for each item of the array. Illustration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4]; 
numbers.forEach((num) =&amp;gt; console.log(num));
// Output: 1, 2, 3, 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. map()
&lt;/h3&gt;

&lt;p&gt;This higher-order function returns a new array based on the results from the function passed in as an argument and called on each element of the original array.&lt;/p&gt;

&lt;p&gt;Illustration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5];  
const doubledNumbers = numbers.map((num) =&amp;gt; num * 2);  
console.log(doubledNumbers);
// Output: [2, 4, 6, 8, 10]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Each element from the numbers array is multiplied by 2 to create a new array through the &lt;strong&gt;map()&lt;/strong&gt; method.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. sort()
&lt;/h3&gt;

&lt;p&gt;As the name suggests when called on an array it sorts it and returns it in default ascending order. Under the hood though, it changes each element into a string and compares their sequence.&lt;/p&gt;

&lt;p&gt;You could use &lt;strong&gt;sort&lt;/strong&gt; without passing a function in as an argument, however, this only works well for string arrays but not for numbers.&lt;/p&gt;

&lt;p&gt;Hence if you’re going to use &lt;strong&gt;sort&lt;/strong&gt; on numbers you pass in a compare function as an argument. The compare function takes 2 arguments. Illustration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [6, 9, 3, 1]; 
numbers.sort((a, b) =&amp;gt; a - b); 
// After sorting: [1, 3, 6, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the code above:&lt;/p&gt;

&lt;p&gt;The negative value (a &amp;lt; b) =&amp;gt; a will be placed before b&lt;/p&gt;

&lt;p&gt;The zero value (a== b) =&amp;gt; No change&lt;/p&gt;

&lt;p&gt;The positive value (a &amp;gt; b) =&amp;gt; a will be placed before b&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. filter()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method returns a new array with all elements that satisfy the condition implemented by the function passed. The function passed should always return a boolean value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4]; 
const evenNumbers = numbers.filter((num) =&amp;gt; num % 2 === 0); 
// Result: [2, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The condition in the body of the passed in function is evaluated for each element in the numbers array to return a new array of only values that satisfy it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5. reduce()
&lt;/h3&gt;

&lt;p&gt;This method takes in 2 arguments a callback function and an initial value. The callback function takes 2 parameters an accumulator (which is set to the initial value at the start) and current value that run on each element in the array to return a single value in the end.&lt;/p&gt;

&lt;p&gt;Illustration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3, 4, 5]; 
const sum = numbers.reduce(function(acc, num) { 
                              return acc + num; 
                           }, 0);

console.log(sum); 
// Output: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The value of acc is 0 and that of num is the first item of the array at the start of execution. As reduce iterates over the array the acc value changes to the value returned after summation. This new value of acc is then applied to the next iteration. This continues until the end of the array.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  3. Functional composition
&lt;/h3&gt;

&lt;p&gt;Functional composition is the act of combining multiple smaller functions by chaining them together to obtain a single more complex function.&lt;/p&gt;

&lt;p&gt;In this approach, a function in the chain operates on the output of the previous function in the composition chain.&lt;/p&gt;

&lt;p&gt;To enable functional composition in JavaScript we use the &lt;strong&gt;compose&lt;/strong&gt; function. A &lt;strong&gt;compose&lt;/strong&gt; function is a higher-order function that, takes in two or more functions and returns a new function that applies these functions in right-to-left order.&lt;/p&gt;

&lt;p&gt;Let's dive into an example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The first step is to define the compose function:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const compose = (...functions) =&amp;gt; {
     return (input) =&amp;gt; {
         return functions.reduceRight((acc, fn) =&amp;gt; {
             return fn(acc);
         }, input);
     };
   };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the above implementation, the &lt;strong&gt;compose&lt;/strong&gt; function takes in any number of functions as arguments by using the &lt;strong&gt;spread&lt;/strong&gt; operator.&lt;/p&gt;

&lt;p&gt;It returns a new function that iterates over the functions in reverse order using &lt;strong&gt;reduceRight&lt;/strong&gt;, applying each function to the accumulated result.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;  The next step is to now use the compose function:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addOne = x =&amp;gt; x + 1; 
const multiplyByTwo = x =&amp;gt; x * 2;
const addOneAndMultiplyByTwo = compose(multiplyByTwo, addOne); 
console.log(addOneAndMultiplyByTwo(5)); 
// Output: 11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Above the entered value is first multiplied by 2 then added a one by applying the functions passed to compose from right to left.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Benefits of Higher Order Functions
&lt;/h3&gt;

&lt;p&gt;We have seen that there are quite several applications for higher-order functions. This indicates that they do offer some benefits to programmers to warrant their use.&lt;/p&gt;

&lt;p&gt;Let’s take a look at these benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt;: Higher order functions allow you to hide the implementation details behind clear function names improving the readability and understanding of code. For instance, without this type of functions iterating over arrays would need the use of loops which can clutter code, especially in a large codebase, and make it more complicated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reusability&lt;/strong&gt;: Higher-order functions encapsulate the same logic into reusable functions. This means they can be reapplied throughout the codebase without the need to create them from scratch at every instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Immutability&lt;/strong&gt;: Many higher-order functions operate on data immutably, creating new structures instead of modifying existing ones. This helps avoid unintended side effects and makes your code more predictable and easier to debug.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modularity&lt;/strong&gt;: Higher-order functions facilitate breaking down complex problems into smaller, manageable parts, promoting modular design.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Common mistakes when working with Higher Order Functions (HOFs)
&lt;/h3&gt;

&lt;p&gt;Higher-order functions do offer numerous benefits as seen above, but it’s essential to be aware of the potential pitfalls that can cause bugs and unexpected results.&lt;/p&gt;

&lt;p&gt;Some common mistakes to avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Not returning a value&lt;/strong&gt;: Most HOFs like map, filter, and reduce expect the function passed in as an argument to return a value for each element processed. In this instance forgetting to return a value can disrupt the chain and lead to undefined results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Not using the correct syntax&lt;/strong&gt;: HOFs can be complex and it’s easy to make syntax errors when creating or using them. A good rule of thumb is to double-check the syntax and ensure functions are properly defined and called.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Not using pure functions&lt;/strong&gt;: HOFs should not cause any side effects thus they should return the same output for a given input, to be pure functions. Using them in an impure manner could lead to unexpected behavior that makes debugging a nightmare.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Overusing composition&lt;/strong&gt;: Functional composition is a powerful programming technical but excessive nesting of HOFs can increase the complexity of code making it harder to read and understand. Aim for a balance between conciseness and clarity, breaking down complex transformations into smaller, more readable steps if necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;As we reach the end, some key takeaways are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Higher-order functions are functions that either take other functions as arguments or return them as output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2. Higher-order functions do have a lot of use cases some of them being in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Callback functions,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Array methods,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functional composition etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3. Higher-order functions benefit programmers by providing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Abstraction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Immutability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modularity&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4. As programmers, there are common mistakes that we may encounter when working with Higher-Order Functions.&lt;/p&gt;




&lt;p&gt;I hope this blog inspires a deeper understanding of higher-order functions and how you might be able to leverage them to solve real-world problems. The journey of learning is never-ending. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is Big-O?</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Sat, 15 Jun 2024 09:29:13 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/what-is-big-o-18c</link>
      <guid>https://dev.to/muchai_joseph/what-is-big-o-18c</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@choys_?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Conny Schneider&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/a-blue-background-with-lines-and-dots-xuTJZ7uD7PI?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;br&gt;
&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/cs"&gt;DEV Computer Science Challenge v24.06.12: One Byte Explainer&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Explainer
&lt;/h2&gt;

&lt;p&gt;It's a way to compare the efficiency of an algorithm in terms of its worst-case performance. Takes 2 forms: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time complexity: How well the running time scales with the input size.&lt;/li&gt;
&lt;li&gt;Space complexity: How well the memory usage scales with the input size.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional Context
&lt;/h2&gt;

&lt;p&gt;Big-O ignores implementation details and constants, focusing solely on how algorithms scale. It enables high-level comparison of algorithms' efficiency, guiding choices for optimal performance across diverse problem sizes and computing environments. Understanding Big-O is crucial for designing effective and scalable solutions in computer science.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>cschallenge</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I learned JavaScript</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Wed, 12 Jun 2024 09:39:27 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/how-i-learned-javascript-22dl</link>
      <guid>https://dev.to/muchai_joseph/how-i-learned-javascript-22dl</guid>
      <description>&lt;p&gt;“Has anyone ever finished learning JavaScript?” I highly doubt any developer’s answer to that question will ever be a profound YES.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I for one question my understanding of JavaScript with every&lt;/em&gt; &lt;a href="https://www.codewars.com" rel="noopener noreferrer"&gt;&lt;em&gt;Codewars&lt;/em&gt;&lt;/a&gt; &lt;em&gt;kata I try to solve.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I got into web development after bouncing off multiple programming languages in my early days as an aspiring developer. This is where I first picked up JavaScript. I had already explored enough with HTML and CSS and my curiosity drove me to seek out some dynamism for my static web pages.&lt;/p&gt;

&lt;p&gt;The best candidate for such was JavaScript given its vast application in web dev.&lt;/p&gt;

&lt;p&gt;My JavaScript learning path has been plagued by quite a number of inconsistencies — most of which were of my own making. The result of this is going through multiple learning materials and resources (most of which are free) as a result of all the recaps I subjected myself to.&lt;/p&gt;

&lt;p&gt;Here are the resources I have utilized in my learning journey so far:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.sololearn.com/" rel="noopener noreferrer"&gt;Sololearn&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.udemy.com/course/javascript-essentials/" rel="noopener noreferrer"&gt;Javascript Essentials&lt;/a&gt; | Lawrence Turton&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/" rel="noopener noreferrer"&gt;FreeCodeCamp&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A Smarter Way To Learn Javascript | Mark Myers&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Sololearn&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sololearn is an easily accessible learning platform that offers on-the-go bit-size lessons on several programming languages (js included) and concepts with quizzes and challenges to test and improve your programming skills. It has an active community where you can connect with other learners on the platform and ask questions, share your projects, participate in challenges and competitions, or just share your coding journey.&lt;/p&gt;

&lt;p&gt;The basic plan has some limited features but it’s still a good bargain considering all certifications earned upon course completion are free. However, if you do wish to access the other added features you can pay for the pro version.&lt;/p&gt;

&lt;p&gt;Sololearn is available on the iOS Apple Store, Google Play store, and on desktop via a browser&lt;/p&gt;

&lt;h3&gt;
  
  
  Javascript Essentials | Lawrence Turton
&lt;/h3&gt;

&lt;p&gt;This is a brilliant introductory course to Javascript that is available for free on Udemy. It has up to six hours of content and covers the basics of JavaScript as well as DOM manipulation and much more. The instructor also delivers the content with utmost simplicity and provides clear explanations in a way that is easy to understand.&lt;/p&gt;

&lt;p&gt;Even though the course does not offer a certification at the end it is still a good way to acquire some javascript knowledge and skills.&lt;/p&gt;

&lt;h3&gt;
  
  
  FreeCodeCamp
&lt;/h3&gt;

&lt;p&gt;FreeCodeCamp is among the most popular learning websites for novice programmers. The main reason is that it offers free coding lessons in various programming languages and certifications upon successful completion. It is also a proven path into beginner roles in the tech industry considering the numerous testimonials from its highly successful alumni.&lt;/p&gt;

&lt;p&gt;The quite extensive freecodecamp curriculum has also undergone some amazing updates in recent months ensuring that it is up to date with modern programming methods and practices. The curriculum provides 300+ hours of hands-on learning and programming practice in the javascript path alone making it a good and effective learning tool in the mastery of javascript.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;A Smarter Way To Learn JavaScript&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;“A Smarter Way to Learn JavaScript” is a book by Mark Myers that quoting the author’s words, “uses a new approach to teach JavaScript with technology to cut your effort in half”. This is achieved simply by cutting down on the time a learner spends passively reading the book and getting them more actively involved in the learning process by providing interactive exercises after each concept on the &lt;a href="http://ASmarterWayToLearn.com" rel="noopener noreferrer"&gt;author’s website&lt;/a&gt;. This ensures clear understandability is achieved before moving on to a new concept.&lt;/p&gt;

&lt;p&gt;The exercises are free and &lt;a href="https://cdn.wccftech.com/wp-content/uploads/2014/10/JavaScript.pdf" rel="noopener noreferrer"&gt;finding the book&lt;/a&gt; online for free isn’t that much of a hassle either. You can also find it on multiple online bookstores like Amazon, Goodreads ...etc. It has received a lot of positive reviews and is a good place to recap or start learning JavaScript.&lt;/p&gt;

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

&lt;p&gt;In conclusion, there are many great online resources available for learning JavaScript. This is by no means an exhaustive list considering I have covered only what I am familiar with. If you have a favorite resource that you’d like to share, please mention it in the comments. As developers, we’re always looking for new and effective ways to learn and improve our skills. Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is the useRef() Hook?</title>
      <dc:creator>Joseph Muchai</dc:creator>
      <pubDate>Tue, 28 May 2024 18:12:38 +0000</pubDate>
      <link>https://dev.to/muchai_joseph/what-is-the-useref-hook-31a9</link>
      <guid>https://dev.to/muchai_joseph/what-is-the-useref-hook-31a9</guid>
      <description>&lt;p&gt;React as a frontend framework encourages a reactive programming model where changes in state lead to component re-rendering. This is what allows React to efficiently keep the UI in sync with changes to underlying data.&lt;/p&gt;

&lt;p&gt;However, there are scenarios in which you may be required to store and access values that should not trigger re-renders when they change. It is in such instances that you require the useRef() hook.&lt;/p&gt;

&lt;p&gt;What is the useRef() hook?&lt;/p&gt;

&lt;p&gt;In this blog, I will answer this question and provide some insight into the best use cases and common pitfalls when working with the useRef().&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;The useRef is a react hook that takes an ‘initial value’ as its argument and returns a mutable ref object whosecurrent property is initialized to the passed argument. The 'initial value' can be of any type. The returned ref object is similar to a normal JavaScript object.&lt;/p&gt;

&lt;p&gt;The ref object persists for the full lifetime of the component and can be used to reference a value that's not needed for rendering. This allows the persisting of values between renders. Thus, refs are perfect for storing information that doesn't affect the visual output of your component.&lt;/p&gt;

&lt;p&gt;Ref objects are useful when you need to access and manipulate elements or components outside the regular React component lifecycle, such as focusing an input element, accessing component methods, or managing state across renders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;To initialize the useRef hook you begin by importing it at the top level like other react hooks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import { useRef } from 'react';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, you can use it in your functional components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MyComp = () =&amp;gt; {    
   //initialize a new ref whose object has the value null 
   const myRef = useRef(null)
   //Change the value of the current property in the myRef object    
   myRef.current = 'Hello'
}   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, we create a new useRef object with a value of null and then proceed to update its value using the current property. It should be noted that changing the value of this ref object doesn't trigger a re-render.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the purpose of the useRef()?
&lt;/h3&gt;

&lt;h3&gt;
  
  
  1. Creating references
&lt;/h3&gt;

&lt;p&gt;One of the primary uses of the useRef is to create references to DOM elements as well as to a React component. These references allow you to interact with and manipulate these elements or components in a controlled and declarative way.&lt;/p&gt;

&lt;p&gt;Let's have a look at each one:&lt;/p&gt;

&lt;h4&gt;
  
  
  a. Using the useRef() to reference DOM elements.
&lt;/h4&gt;

&lt;p&gt;The fact that DOM elements are also objects means that you can reference them using the useRef. React has built-in support for this. To undertake this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  First, import the useRef function from React and create a new ref with an initial value of null:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useRef } from 'react';

const myComponent = () =&amp;gt; {    
  const myRef = useRef(null);    
  //...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Next, you attach the myRef ref to the desired DOM element, say, in this case, input, by assigning it to the ref attribute within your JSX.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//..
return (
  &amp;lt;input ref = {myRef} /&amp;gt;
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  With the ref in place, you can access and manipulate the input element and perform actions such as retrieve properties, measure dimensions, or modify styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, you can invoke the focus() method on the input element by pressing a button, as shown in the following better-organized code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useRef } from 'react';

const MyComponent = () =&amp;gt; {
    const myRef = useRef(null);

    const handleClick = () =&amp;gt; {
        myRef.current.focus();
    }

 return (
    &amp;lt;div&amp;gt;
       &amp;lt;input ref={ myRef } /&amp;gt;
           &amp;lt;button onClick={handleClick}&amp;gt;
           Focus
        &amp;lt;/button&amp;gt;
     &amp;lt;/div&amp;gt;
 );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some applicable use cases where referencing the DOM using useRef may come in handy are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Styling:&lt;/strong&gt; Adjusting styles and classes based on user interactions becomes straightforward with direct access to DOM elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dimension Measurements:&lt;/strong&gt; You can measure the dimensions of elements, allowing for responsive design and layout adjustments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Validation and Feedback:&lt;/strong&gt; Validate user inputs and provide feedback by interacting with the DOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Smooth Animations:&lt;/strong&gt; Effortlessly trigger animations and transitions by changing element properties using refs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  b. Using the useRef() to reference React components.
&lt;/h4&gt;

&lt;p&gt;The useRef() hook provides a way for directly accessing and interacting with a React component from another component (kind of like a more direct, component-to-component communication).&lt;/p&gt;

&lt;p&gt;You can use it to call methods, access properties or manage component state without involving the component's parent.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;While it is possible to use the useRef to access a child component’s methods and properties, it is generally not recommended as it goes against the principles of React’s uni-directional data flow. If you need to manage a child component’s state from a parent component, it is recommended you apply props&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The useRef is most suitable when you need to reference and interact with a specific instance of a component, particularly in managing behavior.&lt;/p&gt;

&lt;p&gt;A good scenario is when you need to call a child component method from the parent component. Props cannot be used in this instance since they only work one way, from parent to child.&lt;/p&gt;

&lt;p&gt;To do this though you also need the forwardRef function in React which allows you to forward a ref from a parent component to one of its child components. forwardRef allows you to maintain encapsulation in the child's component's implementation while still allowing the parent component to reference it.&lt;/p&gt;

&lt;p&gt;Here’s a code example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { forwardRef, useImperativeHandle, useRef } from 'react';

const MyChildComp = forwardRef((props, ref) =&amp;gt; {
  useImperativeHandle(ref, () =&amp;gt; ({
    greeting: () =&amp;gt; {
      alert("Greetings from the Child component");
    }
  }));

  return (
    &amp;lt;div&amp;gt;Child component here!!!&amp;lt;/div&amp;gt;
  );
});

const App = () =&amp;gt; {
  const myRef = useRef();

  const handleClick = () =&amp;gt; {
    myRef.current.greeting();
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Click&amp;lt;/button&amp;gt;
      &amp;lt;MyChildComp ref={myRef} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A brief breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We define a myRef ref, which will be used to create a reference to the child component (MyChildComp) in the App component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The MyChildComp is a child component created with the forwardRef function allowing it to accept a ref attribute.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside MyChildComp, we use the useImperativeHandle hook to define a function, greeting, that can be called from the parent component. The purpose of this function is to display an alert with the message "Greetings from the Child component."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The handleClick function is also defined. When the "Click" button is clicked, it calls myRef.current.greeting(), which in turn triggers the greeting function in the child component resulting in an alert message being displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The child MyChildComp also renders some simple text: "Child component here!!!"&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Output&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Frzsv1fcdtle8eentgnh1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Frzsv1fcdtle8eentgnh1.png" alt="output of the above code" width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Persisting data through renders
&lt;/h3&gt;

&lt;p&gt;The useRef is also used in storing a value and persisting it across renders of a component. The values are stored in the current property of the useRef object.&lt;/p&gt;

&lt;p&gt;Changing these values does not trigger a re-render. Thus, the useRef is a suitable way for storing values that shouldn't affect the component's UI but need to be reserved.&lt;/p&gt;

&lt;p&gt;It is therefore appropriate to use in instances such as when caching data, managing previous state, or in form input validations.&lt;/p&gt;

&lt;p&gt;For a better understanding, here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useRef, useEffect } from 'react';

const Previous = () =&amp;gt; {
    const previousValue = useRef(null);
    const [value, setValue] = useState('Hello')

    useEffect(() =&amp;gt; {
        previousValue.current = value
    }, [value])

    return (
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;Previous value: {previousValue.current}&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Current value: {value}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We initialize a previousValue ref and set its initial value to null. We also create a state variable value using useState and initialize it with the string 'Hello'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the useEffect, you update the previousValue.current with the current value of the value state variable whenever it changes. This explains why we have it set as a dependency in the useEffect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The UI displays both the previous value and the current one. When the value state changes, the useEffect updates previousValue.current, allowing you to display both the previous and current values in the UI.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Common Pitfalls when using the useRef hook.
&lt;/h3&gt;

&lt;p&gt;The useRef() hook is a useful hook as described above, but it also has some potential pitfalls that you should be aware of.&lt;/p&gt;

&lt;p&gt;Some of them include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Not triggering a re-render&lt;/strong&gt;: Unlike useState, useRef does not cause a re-render when its value changes. This can be useful for performance reasons, but it can also lead to stale or inconsistent UI if you rely on the refvalue for rendering. To avoid this, you should always use useState or useEffect to update the UI when the ref value changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Not Using It for DOM Manipulation:&lt;/strong&gt; useRef is often associated with DOM manipulation as shown earlier, precisely when referencing DOM elements. However, it's important to ensure that you're using it appropriately and not modifying the DOM directly outside of React's virtual DOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using refs for derived state&lt;/strong&gt;: Refs are meant to store values that are not directly related to the UI state, such as DOM nodes, timers, or subscriptions. However, sometimes you may be tempted to use refs for values that are derived from props or state, such as computed values or previous values. This can lead to bugs and confusion, as refs do not participate in the React data flow and do not update automatically when props or state change. To avoid this, you should use useMemo or usePrevious hooks instead of refs for derived state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using refs for anti-patterns&lt;/strong&gt;: Refs can also be used for anti-patterns that violate the React principles of declarative programming and unidirectional data flow. For example, you may use refs to store global variables, manipulate props or state directly, or call child component methods imperatively. These practices can make your code harder to understand, test, and maintain. To avoid this, you should follow the React best practices and use hooks like useContext, useReducer, or custom hooks instead of refs for these scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The useRef as seen in this blog is best suited for when you need to persist values across renders and also when you need to create references.&lt;/p&gt;

&lt;p&gt;It is a rather peculiar React hook in that for effective use, you as the programmer are required to fully understand when and where to use it for the best outcome in your program while keeping in mind the expected React programming principles to avoid pitfalls (tiny crazy incidents😞).&lt;/p&gt;

&lt;p&gt;I hope this blog helps in building that understanding. Happy coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
  </channel>
</rss>
