Skip to main content
CalcChef

CSS Triangle Generator

Generate a CSS triangle or arrow pointing in any of eight directions. Set the size and color, then copy border CSS, a ::after rule, a clip-path or an SVG. How it works

Use the CSS Triangle Generator

Direction
top
100px
100px
The height is set to 0.866 times the width.
0deg
Preview Background
Export Format
CSS
.triangle {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 50px 100px 50px;
  border-color: transparent transparent #007bff transparent;
}

About the CSS Triangle Generator

A CSS triangle is a box with zero width and height whose borders do the drawing. The default here, 100 × 100 px pointing up, is border-width: 0 50px 100px 50px with only the bottom border colored: that border’s width becomes the triangle’s height, and the two transparent side borders each take half its width.

How to use this tool

  1. Pick a direction on the compass: up, down, left and right give isosceles triangles, the four corners give right-angled ones.
  2. Set Width and Height with the sliders (0 to 300 px) or type up to 999 px, or press a square preset: Caret 10, Tooltip 16, Arrow 20, Pointer 40 or Large 80 px.
  3. Tick Equilateral for a triangle with three equal sides (height 0.866 × width when it points up or down), and set Rotation from 0 to 360° to turn it.
  4. Choose the color, check it on the White, Black or Checker preview, then copy the code as CSS, CSS Var, Pseudo, Clip Path or SVG.

Frequently asked questions

How do I add a CSS arrow to a tooltip?
Choose direction Bottom so the arrow points down out of the box, set the color to the tooltip background, and pick the Pseudo format. It writes the whole .tooltip::after rule (or your own selector, and ::before if you prefer) with content: ""; position: absolute; and the borders. Give the tooltip position: relative, then add top: 100%; left: 50%; transform: translateX(-50%) to the rule. If you also set a rotation, put both in one line, transform: translateX(-50%) rotate(30deg), because a second transform replaces the first.
How do I make an equilateral triangle in CSS?
Tick Equilateral. For a triangle pointing up or down the height becomes 0.866 × the width, because the height of an equilateral triangle is √3 ÷ 2 of its side: a 100 px base gives border-width: 0 50px 86.6px 50px. For left and right the width follows the height instead. The corner directions are right-angled, so the box is disabled there.
Why does my CSS triangle look blurry?
An odd width is split into half pixels. Width 101 pointing up writes 50.5px side borders, which some screens draw with soft edges. Use an even width for up and down triangles and an even height for left and right ones.
Can a CSS border triangle have an outline or shadow?
Not directly. box-shadow and outline follow the element’s square box, not the colored border. Copy the SVG version instead and add a stroke to the polygon, or use filter: drop-shadow() on the triangle.
How do I make a CSS triangle with clip-path?
Choose Clip Path. The default 100 × 100 px up triangle becomes width: 100px; height: 100px; background: #007bff; clip-path: polygon(50% 0, 0 100%, 100% 100%). The element needs that width and height, unlike the border method, and in return its background can be a gradient or an image. For other polygons, the CSS clip-path generator draws them point by point.
What does the CSS Var format write?
The same rule with the colored border replaced by var(--triangle-color, <your color>), so you can recolor the arrow from a parent. The fallback is the color you picked, for example var(--triangle-color, #ff6600), and it applies whenever --triangle-color is not set.

Related Tools

View all tools