React Portflio Website Basic to Advance
To build a React-based portfolio website with Tailwind CSS, follow these steps to integrate Tailwind and style your components.
1. Set Up Tailwind CSS in Your React Project
tailwind.config.js
as follows:tailwind.config.js
2. Add Tailwind Directives to CSS
Create a new file src/index.css (or edit the existing one) to include the Tailwind directives:
src/index.css
3. Run the Application
Now that everything is set up, you can run the app using the following command:
This will open your portfolio website with Tailwind CSS applied
To create a portfolio website using React.js with various components like `About`, `Blog`, `Footer`, `Hero`, `Navbar`, `Portfolio`, `Service`, `Testimonial`, and pages like `About`, `Blog`, `Home`, and `Portfolio`, you can structure your React app with multiple components and use React Router for navigation.
Final Structure
Here’s a quick recap of the structure
Additional Features
2. Install React Router
npm i react-router-dom
App.js
import React from 'react'import { BrowserRouter, Routes, Route } from "react-router";import Home from './page/Home';import Blog from './page/Blog';import About from './page/About';import Portflio from './page/Portflio';import Navbar from './Components/Navbar';import Footer from './Components/Footer';
const App = () => { return ( <BrowserRouter> <Navbar /> // render in everypage <Routes> <Route path='/' element={<Home />}/> <Route path='/About' element={<About />} /> <Route path='/blog' element={<Blog />}/> <Route path='/portflio' element={<Portflio />}/> </Routes> <Footer /> </BrowserRouter> )}
export default App
Navbar
and Footer
components are the same across all pages in your application, it makes sense to place them outside of the Routes
component. This way, both the Navbar
and Footer
will be rendered on every page, and you can keep the routing logic cleaner.Homepage.js
How to Used Font in our Website
1.Using Web Fonts (Google Fonts, etc.)
Steps:
2. Import the Font in CSS**:
2. Using Custom Fonts with `@font-face`
Steps:
1. Add Your Font Files:
2. Define `@font-face` in Your CSS:
3. Using Fonts with a CSS Framework (e.g., Tailwind CSS)
1. Install Tailwind CSS:
2. Extend Tailwind Configuration:
3. Apply the Custom Font in Your Components:
4. Using Fonts with Styled Components (CSS-in-JS)
How To used Icon in React js
1. Using React Icons Library
React Icons is a popular library that provides easy access to a wide variety of icons, including popular icon sets like Font Awesome, Material Design, and more.
1) Install the React Icons Library:
First, you need to install the react-icons
library via npm:
2) Import Icons in Your React Component: After installation, you can import specific icons you want to use from the library. For example, to use Font Awesome icons:
2. Using Font Awesome (CDN)
index.html
file.Steps to Add Font Awesome Icons:
Add Font Awesome CDN: In your
public/index.html
, add the following<link>
tag inside the<head>
:
2. Use Font Awesome Icons in Your Components: You can now use Font Awesome icons by simply adding the appropriate class to an HTML element in your React components.
Used full Vs code Extension Extension
1. Get IntelliSense for Tailwind CSS
To enable IntelliSense for Tailwind CSS in your code editor (e.g., Visual Studio Code), install the Tailwind CSS IntelliSense extension.
For Visual Studio Code
After installation, it will automatically provide autocompletion, syntax highlighting, and linting for Tailwind CSS classes in your project.
2. ES7 React/Redux/React-Native/JS snippets:
Once installed, this extension will provide several useful snippets. Here are some of the most common ones:
React Snippets
- Component snippets:
- rafce: Creates a functional component with an export.rafcp: Creates a functional component with a prop type definition.rcc: Creates a class component.rconst: Creates the constructor method for a class component.
3. React Theme Extension
Choosing the best theme for React development in Visual Studio Code (VS Code) depends on your personal preferences for syntax highlighting, visual aesthetics, and comfort during long coding sessions. However, here are some of the most popular and widely recommended themes for React development:
All of these themes are available in the Visual Studio Code Extensions Marketplace, so you can easily install and experiment with them to see which one suits your React development style best!
How to write reusable tailwind css code
To write dynamic and reusable CSS or Tailwind CSS code, you can follow different approaches depending on your project structure and needs. Below are a few techniques to make your styles flexible, reusable, and maintainable.
1. Reusable Tailwind Classes with Custom CSS
You can use the @apply
directive in your CSS files to create reusable custom classes that combine multiple Tailwind utility classes. This allows you to group common styles into a single class, making your code more maintainable and reusable.
2. Creating Custom Tailwind CSS Utility Classes with @layer
You can extend Tailwind's default utility classes by adding your own custom utilities in your tailwind.config.js
or by using @layer
in your CSS file. This allows you to define reusable utilities for things like custom margins, paddings, or text sizes.
Example: Custom Utility Classes in Tailwind
tailwind.config.js:
dynamic css code
Comments
Post a Comment