1. Home
  2. CSS Tools
  3. CSS Triangle Generator

CSS Triangle Generator

Generate pure CSS triangles pointing in any of eight directions with custom width, height and color, perfect for tooltips and dropdown arrows.

Direction
CSS code

Runs locally in your browser. Your files and data are never uploaded or stored.

About the CSS Triangle Generator

CSS triangles are built with a clever border trick: an element with zero width and height, where three borders are transparent and one is colored, displays as a triangle. The CSS Triangle Generator calculates those border values for you in any of eight directions.

Pure CSS triangles are lightweight and crisp on all screens, making them ideal for tooltip pointers, speech bubbles, dropdown carets, breadcrumb arrows, ribbons and decorative corners. Set the width, height and color, preview the result and copy the ready-to-use code.

How to use the CSS Triangle Generator

  1. Choose the direction the triangle should point.
  2. Set the width and height with the sliders.
  3. Pick a color.
  4. Copy the CSS into your stylesheet, usually on a ::before or ::after pseudo-element.

Frequently asked questions

How do I add a triangle to a tooltip?

Apply the generated CSS to a ::after pseudo-element with content: "" and position it absolutely at the edge of the tooltip.

Can CSS triangles have borders or shadows?

Not directly. For outlined triangles, stack two triangles of different sizes, or use clip-path for more complex shapes.

Is clip-path better than the border trick?

clip-path is more flexible, but the border technique works everywhere and is perfect for small arrows.