CSS Triangle Generator

Generate a CSS triangle for tooltips, dropdown carets, speech bubbles and arrows. Choose one of eight directions, set the width, height and color, and copy CSS that uses either the classic zero-size border trick — which works everywhere — or clip-path, which can be filled with a gradient or image. It's free, runs in your browser, and nothing is sent anywhere.

Which border to color

PointingColored borderTransparent borders
Upbottomleft, right
Downtopleft, right
Leftrighttop, bottom
Rightlefttop, bottom

When to use it

  1. Add the little arrow to a tooltip or popover.
  2. Draw a dropdown caret without an icon font.
  3. Make a speech-bubble tail.
  4. Create corner ribbons and diagonal section dividers.

How to Use

  1. Pick a direction.
  2. Set the width and height.
  3. Choose the color and technique.
  4. Copy the CSS.

Features

  1. Eight directions including corners
  2. Independent width and height
  3. Border or clip-path output
  4. Live preview
  5. 100% client-side

FAQs

How does the border triangle work?

A box with no width or height has borders that meet diagonally. Color one border, make its neighbors transparent, and what's left is a triangle pointing away from the colored side.

Border or clip-path — which should I use?

Borders work everywhere but only in a solid color. clip-path triangles can have gradients, images and shadows via filter: drop-shadow.

How do I add a triangle to a tooltip?

Put it on the tooltip's ::before or ::after with position: absolute and paste the declarations from here.

Can a border triangle have a shadow?

Not with box-shadow. Use filter: drop-shadow() on it or its parent, or use the clip-path version.

Is anything uploaded?

No. The CSS is generated in your browser.

Technical Details

The classic CSS triangle is a box with zero width and height whose borders meet at angles. Coloring one border and making the two next to it transparent leaves a triangle pointing away from the colored side — so an upward triangle has a colored bottom border, which is the detail people most often get backwards. For up and down, the left and right borders are each half the base width and the colored border sets the height; left and right swap the axes. Corner triangles use just two borders, one colored and one transparent. This technique works in every browser ever made but can only be a flat color. The alternative is a normally sized box clipped with clip-path: polygon(), which can take gradients, images and filters. The generator writes either, from the same direction, width, height and color.

Web & CSS Tools

Web & CSS Tools

  • CSS Text Glitch Generator
  • React Native Shadow Generator
  • CSS Specificity Calculator
  • CSS Color & Property Extractor
  • Responsive Breakpoint Cheatsheet
  • Google Fonts Pair Finder
  • CSS Clamp Generator
  • Fluid Type Scale Generator