react-tailwind-starter-template Tailwind Templates

React Tailwind Starter Template

๐Ÿš€ A ready-to-use starter template for React and TailwindCSS, featuring dark mode. Perfect for kickstarting your next project!

๐Ÿ’ปReact and TailwindCSS: A Ready-to-Use Starter Template

This project is a basic template ready to use with React and TailwindCSS. It includes dark mode configurations.

๐Ÿ”ง Prerequisites

  1. Node.js

๐Ÿ›  Installation

  1. Clone this repository:

    git clone https://github.com/jess-ar/react-tailwind-starter-template.git
    
  2. Access the project:

    cd react-tailwind-starter-template
    
  3. Install the dependencies:

    npm install
    

๐Ÿ“ฆTailwind Configuration

This project already includes the most relevant TailwindCSS configuration, but you can customize it to your liking.

๐ŸŒˆ Theme Customization

The template comes with custom CSS variables defined in src/index.css to manage light and dark themes. These variables are expressed in rgb to ensure that the colors are directly visible in most code editors, making them easier to visualize.

  • Light mode: The colors are defined in the section :root.
  • Dark mode: The colors are defined in the .dark class.

If you use Visual Studio Code, the RGB values will be displayed as a small color preview box, making it easier to understand the colors you're using in the project, but you can adjust them to your liking.

๐Ÿš€ Starting the Project

  • Development:
    npm run dev
    
    Use this command to start the development server. The server will automatically reload when changes are detected in your code.

๐Ÿ“‚ Alias Configuration

To simplify imports and make the codebase easier to navigate, an alias @ is set up to refer to the src directory. This allows you to import components, utilities, and other files from the src folder without needing to use relative paths.

For example, instead of writing:

import Button from '../../components/Button';

You can write:

import Button from '@/components/Button';

This configuration is defined in the vite.config.js file:

resolve: {
 alias: {
   "@": path.resolve(__dirname, "./src"),
 },
  },

The path module from Node.js is used to resolve absolute paths in the project, ensuring that the alias @ points to the correct directory regardless of the environment you're working in.

Benefits:

  1. Avoid long relative paths: Using relative paths (like ../../) can become confusing as the project grows, especially when you move or refactor files.
  2. Cleaner code: The code becomes more readable and easier to follow.
  3. Easy to adapt: If you decide to change the folder structure later on, you only need to update the alias in the configuration, without having to change all the imports.

๐Ÿ–ผ Screenshots

Light Mode:

Light Mode

Dark Mode:

Dark Mode

๐ŸŽ‰ That's all, folks!

Thanks for checking out this project! If you enjoyed it, feel free to give it a โญ๏ธ on GitHub and follow me for more awesome projects!

Let's stay connected:

Got any questions or just want to say hi? Shoot me a message โ€” I'd love to hear from you! โœจ

Top categories

Loading Svelte Themes