Lädt...


🔧 Try Vite + React + Tailwind CSS


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Intro

This time, I will try creating a React application by Vite.
And I will also try using Tailwind CSS.

Creating a React project

First, I will create a React project using Vite by following the "Getting Started".

npm create vite@latest my-react-app -- --template react-ts

After creating the project, I will install Tailwind CSS, PostCSS, autoprefixer.

To use TailWind CSS, I should execute "npx tailwindcss init" and add "postcss.config.js".

postcss.config.js

export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

And I change the "tailwind.config.js" like below.

tailwind.config.js

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

After that, I also need to add these three rows into "index.css".

index.css

@tailwind base;
@tailwind components;
@tailwind utilities;

...

To avoid "Unknown at rule @tailwind" on VSCode, I should install "Tailwind CSS IntelliSense" and add "Files: Associations" into VSCode settings.

warning

Image description

settings.json

Image description

After installing, I can write like below.

App.tsx

import "./App.css";
import {
  BrowserRouter as Router,
  Route,
  Routes,
  Link
} from "react-router-dom";
import { IndexPage } from "./IndexPage";

function App() {
  return (
    <>
      <div className="w-full h-screen flex flex-col items-center justify-center">
        <div className="w-[86%] h-[90%] bg-[green]">
          <Router>
            <Link to="/">TOP</Link>
            <Routes>
              <Route path="/" element={<IndexPage />} />
            </Routes>
          </Router>
        </div>
      </div>     
    </>
  )
}

export default App

Environmental variables

I can use environmental variables by ".env", ".env.development(for development)", and ".env.production(for production)".
In Vite projects, variable names have to be prefixed with "VITE_".

.env

VITE_SERVER_APP_URL="http://localhost:3000"

I can get the value like below.

Index.page.tsx

import "./IndexPage.css";
import { useEffect, useState } from "react";

export function IndexPage(): JSX.Element {
  useEffect(() => {
    fetch(`${import.meta.env.VITE_SERVER_APP_URL}/pointclouds`, {
      mode: "cors",
      method: "GET"
    }).then(res => res.json())
    .then(res => console.log(res))
    .catch(err => console.error(err));
  }, []);
...
}
export default IndexPage;
...

🔧 Try Vite + React + Tailwind CSS


📈 47.35 Punkte
🔧 Programmierung

🔧 How to Setup React and Tailwind CSS with Vite in a Project


📈 38.05 Punkte
🔧 Programmierung

🔧 ## Dev Blog: Launching the Vite + React + Tailwind CSS Starter Template


📈 38.05 Punkte
🔧 Programmierung

🔧 Building a Modern Website with React, Tailwind CSS, and Vite


📈 38.05 Punkte
🔧 Programmierung

🔧 Setting Up Project React and TypeScript Application with Vite and Tailwind CSS


📈 38.05 Punkte
🔧 Programmierung

🔧 Build a Profit Margin Calculator with Vite.js + React.js, TypeScript and Tailwind CSS


📈 38.05 Punkte
🔧 Programmierung

🔧 Tailwind CSS vs. Traditional CSS in a React app: Pros, Cons, and Best Use Cases


📈 31.31 Punkte
🔧 Programmierung

🔧 Create React project with Vite and set up Tailwind, shadcn/ui


📈 30.8 Punkte
🔧 Programmierung

🔧 React + Vite + Tailwind project


📈 30.8 Punkte
🔧 Programmierung

🔧 Vite React Tailwind Starter Repository


📈 30.8 Punkte
🔧 Programmierung

🔧 TailGrids React: 600+ Tailwind CSS React UI Components


📈 30.01 Punkte
🔧 Programmierung

🔧 Tailwind Catalyst: Getting Started with Tailwind's React Toolkit


📈 27.67 Punkte
🔧 Programmierung

🔧 Create reusable button Components with React,Typescript , Tailwind and Tailwind-variants


📈 27.67 Punkte
🔧 Programmierung

🔧 How to implement a Multi-Select Dropdown component with React and Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 Creating a Stylish 404 Not Found Page in React with Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 Tailwind CSS in React - Creating Modal Popup


📈 24.06 Punkte
🔧 Programmierung

🔧 How to implement a slider element using React, Tailwind.css and Intersection Observer API


📈 24.06 Punkte
🔧 Programmierung

🔧 Implementing Drag and Drop to Arrange/Sort Items with React, Tailwind CSS, and Dnd-kit


📈 24.06 Punkte
🔧 Programmierung

🔧 Using Tailwind CSS with React.js: A Concise Guide


📈 24.06 Punkte
🔧 Programmierung

🔧 Implementing Drag and Drop to Arrange/Sort Items with React, Tailwind CSS, and Dnd-kit


📈 24.06 Punkte
🔧 Programmierung

🔧 Como deixar componentes React mais organizados mesmo com Tailwind CSS?!


📈 24.06 Punkte
🔧 Programmierung

🎥 Full Stack Tutorial – Fiverr Clone with NextJS, React, Convex, Typescript, Tailwind CSS, ShadCN


📈 24.06 Punkte
🎥 Video | Youtube

🔧 React Tailwind CSS Forgot Password Example


📈 24.06 Punkte
🔧 Programmierung

🔧 Reasons to Use Tailwind CSS in React Native Development Projects


📈 24.06 Punkte
🔧 Programmierung

🔧 Let's create an animated Drawer using React and Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 How to add Tailwind CSS Carousel React (no library)


📈 24.06 Punkte
🔧 Programmierung

🔧 React with Tailwind CSS File Upload Example


📈 24.06 Punkte
🔧 Programmierung

🔧 How to build a portfolio website with React & Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 Integrasi Tailwind CSS dengan React JS dan Vitejs


📈 24.06 Punkte
🔧 Programmierung

🔧 The Tale of Tailwind CSS and React


📈 24.06 Punkte
🔧 Programmierung

🔧 A Journey with React, Tailwind CSS, and 3D Magic 🎨✨


📈 24.06 Punkte
🔧 Programmierung

🔧 Easy Todo List App with React and Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 Honeypot for Spam Prevention React & Tailwind CSS


📈 24.06 Punkte
🔧 Programmierung

🔧 Let's create Data Table with React, TanStack Table and Tailwind CSS. Part 1: Intro and HTML layout


📈 24.06 Punkte
🔧 Programmierung

🔧 Writing cleaner code with Tailwind CSS in React


📈 24.06 Punkte
🔧 Programmierung

matomo