CSS Triangle Generator

Make pure CSS triangles and arrow tips for tooltips and menus, then copy the code.

FreeNo sign-upPrivate — runs in your browser

Direction

CSS

How to use the CSS Triangle Generator

  1. Choose a directionClick one of the 8 arrows to set which way the triangle points.
  2. Set size and colorAdjust width, height and color, and choose the border or clip-path method.
  3. Copy the CSSCopy the .triangle class, or use it on a ::before or ::after pseudo-element for tooltip arrows.

Example

Pointing up, 120 × 100: border-left: 60px solid transparent; border-right: 60px solid transparent; border-bottom: 100px solid #0e5e6f;

The clip-path version: clip-path: polygon(50% 0, 100% 100%, 0 100%); on a 120 × 100 box.

Frequently asked questions

How does the border trick work?

An element with no width or height but thick borders is drawn as four triangles meeting in the middle. Making three borders transparent leaves one visible triangle.

Border or clip-path: which is better?

Borders work everywhere and are ideal for small tooltip arrows. clip-path is easier to read, can take gradients and images as a background, and works in all modern browsers.

How do I add a triangle to a tooltip?

Put the CSS on .tooltip::after with content: ""; position: absolute; and place it at the edge of the tooltip, for example top: 100%; left: 50%; transform: translateX(-50%).

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester