Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Tailwind CSS Tutorial
  • Tailwind Interview Questions
  • Tailwind Layout
  • Tailwind Flexbox
  • Tailwind Grid
  • Tailwind Alignment
  • Tailwind Spacing
  • Tailwind Sizing
  • Tailwind Typography
  • Tailwind Backgrounds
  • Tailwind Borders
  • Tailwind Effects
  • Tailwind Filters
  • Tailwind Tables
  • Tailwind Transitions and Animation
  • Tailwind Transforms
  • Tailwind Interactivity
  • CSS Frameworks
  • Web Technology
Open In App
Next Article:
How to create a Chevron Arrow using CSS ?
Next article icon

How to create a Chevron using Tailwind CSS ?

Last Updated : 09 Feb, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A Chevron is a basic geometric shape that is used in websites to indicate directional movements or navigation. By utilizing specific border properties and transformations, a chevron shape can be achieved without the need for custom CSS. Tailwind's utility-first approach allows for a straightforward and efficient implementation of complex geometric shapes like chevrons.

Table of Content

  • Chevron using borders
  • Chevron using position

Chevron using borders

This approach involves using a border utility class to create a chevron shape. If we apply a border to a square in any two consecutive directions and rotate the element at 45 degrees. It will form a chevron.

Syntax

<div class="w-[width]  h-[height] border-t-[thickness] 
border-r-[thickness] transform rotate-45">
</div>

Example: Implementation to create a chevron using border of tailwind CSS.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8" />     <meta name="viewport" content=           "width=device-width, initial-scale=1.0" />     <script src="https://cdn.tailwindcss.com"></script>     <title>Tailwind CSS Chevron</title> </head>  <body>     <div class="max-w-xl mt-24 mx-auto">         <p class="font-bold underline text-gray-600">             Chevron using Borders in TailwindCSS         </p>         <div class="flex space-x-24 mt-10">             <div class="w-16 border-pink-600 h-16                          border-t-2 border-r-2                          transform rotate-45 border-gray-800">             </div>             <div class="w-16 border-green-600 h-16                          border-l-2 border-b-2 transform                          rotate-45 border-gray-800">             </div>             <div class="w-16 h-16 border-yellow-600                          border-r-2 border-b-2 transform                          rotate-45 border-gray-800">             </div>             <div class="w-16 h-16 border-sky-600                          border-t-2 border-l-2 transform                          rotate-45 border-gray-800">             </div>         </div>     </div> </body>  </html> 

Output:

cv1
chevron using borders in tailwindcss

Chevron using position

In this approach, we overlap two sqaure, rotate both of them to 45 degree and then shift the upper div a few pixels to right, left, up or down to create respective chevron. The translate-x and translate-y utilities are used to shift the positioning of the upper sqaure.

Note: The backgroud color of the overlapping div should be same as the background color of parent div.

Syntax

<div class="relative bg-{parent} w-[width] h-[height] ">
<div class="absolute bg-[color1] w-[child-width]
h-[child-height] rotate-45">
</div>
<div class="absolute bg-{parent} w-[child-width]
h-[child-height] rotate-45 -translate-x-[shift-x] -translate-y-[shift-y]">
</div>
</div>

Example: Implemetation of chevron using position.

HTML
<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8" />     <meta name="viewport" content=           "width=device-width, initial-scale=1.0" />     <script src="https://cdn.tailwindcss.com"></script>     <title>Tailwind CSS Chevron</title> </head>  <body>     <div class="max-w-xl mx-auto mt-24">         <p class="font-bold underline text-gray-600">             Chevron using Position in TailwindCSS         </p>          <div class="flex space-x-24 mt-10">             <div class="relative w-16 h-16">                 <div class="absolute bg-pink-600                              w-14 h-14 rotate-45">                 </div>                 <div class="absolute bg-white w-14                              h-14 rotate-45 -translate-x-1">                 </div>             </div>              <div class="relative w-16 h-16">                 <div class="absolute bg-green-600                              w-14 h-14 rotate-45">                 </div>                 <div class="absolute bg-white w-14                              h-14 rotate-45 translate-x-1">                 </div>             </div>              <div class="relative w-16 h-16">                 <div class="absolute bg-yellow-600                              w-14 h-14 rotate-45">                 </div>                 <div class="absolute bg-white w-14                              h-14 rotate-45 -translate-y-1">                 </div>             </div>              <div class="relative w-16 h-16">                 <div class="absolute bg-blue-600                              w-14 h-14 rotate-45">                 </div>                 <div class="absolute bg-white w-14                              h-14 rotate-45 translate-y-1">                 </div>             </div>         </div>     </div> </body>  </html> 

Output:

cv2
chevron using position in tailwindcss

Next Article
How to create a Chevron Arrow using CSS ?
author
prateekpranveer321
Improve
Article Tags :
  • Web Technologies
  • Tailwind CSS
  • Tailwind CSS-Questions

Similar Reads

  • How to create a Chevron Arrow using CSS ?
    In the article, we will see how to make a Chevron Arrow using CSS. A Chevron Arrow is an arrow, often used to indicate direction or to represent navigation elements. Creating a chevron arrow using CSS involves using CSS properties like border and transform to generate the arrow shape. Syntaxtransfor
    3 min read
  • How to centre an Element using Tailwind CSS ?
    Tailwind CSS follows a utility-first approach, which means that instead of writing custom CSS for each component, we can utilize pre-defined classes that apply specific styles directly to HTML elements. We can center an element by using the utility classes of "margin" and "flex". This article will g
    3 min read
  • How to create a skewed background using CSS ?
    A skewed background design enhances a website's visual appeal with dynamic, angled elements. By using CSS transform: skew() along with ::before and ::after pseudo-elements, you can easily create a slanted effect, adding a modern and engaging look to your site's layout. ApproachHTML Structure - Secti
    2 min read
  • How to Build a Card component using Tailwind CSS ?
    In this article, we will learn about how to Build a card component using Tailwind CSS, Tailwind CSS is a CSS framework that helps in building rapid custom UI. It is a highly customizable, low-level CSS framework that gives you all of the building blocks that you need. Tailwind CSS creates small util
    4 min read
  • How to Create Animated Loading Button using Tailwind CSS?
    An Animated Loading Button is a button that displays a loading spinner or animation to indicate an ongoing process, such as form submission. Using Tailwind CSS, you can create this by combining utility classes for styling and animations to visually enhance the button during loading. Table of Content
    2 min read
  • How to Create a Ribbon using CSS?
    In this article, we will learn how to create a ribbon using CSS. PrerequisitesHTMLCSSApproachThe structure consists of a <button> element with the class "btn" containing the text "GFG DSA Course". Inside the button, there is an <span> element with the class "ribbon" containing the text "
    2 min read
  • How to Create A Sticky NavBar Using Tailwind CSS?
    Sticky Navbar in Tailwind CSS is mostly used in applications where maintaining quick access to navigation links is essential as users scroll through content. It ensures that the navbar remains visible at the top of the screen, enhancing user experience by providing constant access to key sections of
    4 min read
  • Create Checkboxes UI using React and Tailwind CSS
    Web forms rely on checkboxes to allow users to choose one option or multiple of several options. In the following post, we are going to walk through how to create a simple and reusable checkbox UI in React using Tailwind CSS. We will go over setting up the project, implementing the component, and st
    5 min read
  • Create Buttons UI using React and Tailwind CSS
    Tailwind CSS is a utility-first CSS framework that allows developers to quickly build responsive and reusable components. We'll explore how to create buttons with different styles such as primary, secondary, and disabled states, and buttons of various sizes. PrerequisitesReact JavaScriptNodeJSTailwi
    2 min read
  • How to Create a Rounded Card in Tailwind CSS ?
    A rounded card is a design used in web development, featuring rounded corners and typically containing content or information within a defined boundary. To create a rounded card in Tailwind CSS, use the rounded utility class along with the bg-white and shadow-md classes for a clean, rounded look. Sy
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences