CSS Triangle Generator
Border Trick or Clip-Path
Pick a direction and copy the CSS. Make an isosceles, equilateral, right-angled or scalene triangle in eight directions, see the transparent-border trick and clip-path side by side, and attach it to a tooltip or speech bubble with the right ::after offsets. Tailwind classes included. 100% client-side. Zero data stored.
CSS Triangle Generator Tool
Shape a Triangle
Direction
Up, down, left and right point that way. A corner button puts the right angle in that corner.
0 or 100 gives a right-angled triangle; anything else off-center is scalene.
Transparent-border trick
- Works in every browser, however old.
- Cannot take a border, a gradient or an image of its own.
- box-shadow follows the empty box, so use filter: drop-shadow.
- Sized in pixels through the border widths.
CSS
Tailwind CSS
clip-path: polygon()
- Can hold a gradient, an image or a video.
- Sized as a box, so the percentages scale with it.
- Cuts off its own shadow and border; put filter: drop-shadow on a wrapper.
- Needs a current browser; very old ones ignore it.
CSS
Tailwind CSS
Previews are scaled down to fit when the triangle is larger than 220 px; the code always uses the real size. The apex of the border version is rounded to a whole pixel, the clip-path version uses the percentage.
Tooltip and Speech Bubble
The same triangle as a ::after arrow on a box. Its shape comes from the settings above, so turning the tooltip to another side never changes the arrow.
The center of the arrow base sits at this share of the edge, kept between 10% and 90% so it stays on the box.
A rounded tip is not possible with the border trick or a polygon: both give a sharp point. For a soft tip, draw the arrow as an inline SVG path with stroke-linejoin round, or rotate a small rounded square by 45 degrees behind the box.
CSS (box and ::after rule)
Tailwind CSS
One class list for the box and its ::after arrow. Tailwind sets border-style to solid in its base layer, so the border technique relies on that layer, which is on by default.
Common Use Cases
Tooltips and Popovers
Attach a small arrow to a hint box on any side with the right ::after offsets, centered or moved along the edge.
Speech Bubbles and Chat
Give a message bubble a tail. Put the arrow on the left or right edge and slide it near the corner.
Dropdown Carets
Make a small pointing caret for a select, a menu or an accordion with no icon font and no image request.
Ribbons and Corner Folds
Use a right-angled corner triangle for a folded corner, a ribbon end or a diagonal cut on a card.
Breadcrumb and Step Arrows
Turn a step in a wizard or a breadcrumb into an arrow by adding a right-pointing triangle to its end.
Play Buttons and Markers
Draw a play icon, a sort arrow or a map marker tip in a single color that follows your theme variables.
Triangle CSS Reference
Border Trick: Which Border Is Colored
| Direction | Colored border | Transparent borders |
|---|---|---|
| Up | bottom | left and right |
| Down | top | left and right |
| Left | right | top and bottom |
| Right | left | top and bottom |
| Top left corner | top | right |
| Top right corner | top | left |
| Bottom left corner | bottom | right |
| Bottom right corner | bottom | left |
The element has width 0 and height 0. The colored border is the depth of the triangle; the two transparent borders add up to its base, and moving the apex just trades width between them.
Border Trick or clip-path
| Need | Border trick | clip-path |
|---|---|---|
| Oldest browsers | Yes | No |
| Gradient or image fill | No | Yes |
| Own border or outline | No | No (cut off) |
| Shadow that follows the shape | filter on itself | filter on a wrapper |
| Scales with its box | No (pixels) | Yes (percentages) |
| Rounded tip | No | No |
Both are pure CSS with no image and no script, and both are written from the same settings, so you can switch between them without redrawing anything.
Equilateral math
The depth is the base times 0.866 (half the square root of 3). The Equilateral lock rounds to whole pixels, so a 100 px base gives an 87 px depth.
Right-angled and scalene
Move the apex to 0 or 100 for a right angle on the base, use a corner direction for a right angle in a corner, or set any other apex for a scalene triangle.
Not a rounded tip
Neither technique can round the point. Use an SVG path with a round line join if you need a soft tip.
Related tools
Cut any polygon with the Clip Path Generator and add depth with the Box Shadow Generator.
Pro Tip: URL Parameters
Open the tool with a triangle already built. ?dir= is up, down, left, right, top-left, top-right, bottom-left or bottom-right; ?w= and ?h= are the size in pixels; ?a= is the apex position from 0 to 100; ?c= is a hex color without the hash and ?o= its opacity from 0 to 100; ?lock= is free, linked or equilateral; ?g=1 turns on the gradient with ?c2= as its second color; ?sh=1 adds the shadow. For the tooltip, ?side= is top, bottom, left or right, ?pos= is its position from 10 to 90 and ?tt= is border or clip. For example: /css-triangle-generator/?dir=down&w=24&lock=equilateral&c=0d9488
Bad values are ignored and sizes are kept between 1 and 500. The link in your address bar updates only after you change something, and the Copy Link button builds it from your current settings.
Frequently Asked Questions
An element with width 0 and height 0 is just its borders, and where two thick borders meet the browser joins them along a diagonal. Make one border a color and its two neighbors transparent and what is left is a triangle. For an upward triangle the bottom border is colored, and the left and right borders are transparent and half the base each.
Use the border trick when you only need a solid color and want it to work everywhere, including very old browsers. Use clip-path when the triangle needs a gradient or an image, or when it should scale with its box. The tool writes both from the same settings so you can compare them and copy the one that fits.
The depth must be the base times 0.866, which is half the square root of 3, with the apex in the exact center. Choose the Equilateral size lock and the tool computes it for you: type a base of 100 and the depth becomes 87 pixels. Whole pixels mean it is equilateral to within half a pixel, which is invisible in practice.
For a right angle in a corner, pick one of the four corner directions. For a right angle on the base of an up, down, left or right triangle, move the apex position to 0 or 100. Any other apex that is not the center gives a scalene triangle, and the summary under the controls names the triangle and shows its three angles.
The border trick cannot hold its own border, gradient or image because the borders are the triangle, and box-shadow follows the empty box. A filter: drop-shadow on the element does follow the shape. A clip-path triangle can hold a gradient or image, but it cuts off its own shadow and border, so put filter: drop-shadow on a wrapper element instead.
Give the box position: relative and add the triangle as a ::after rule with content, position: absolute and an offset. For an arrow on the top edge use bottom: 100% and left: calc(50% - half the base), which centers it. The other sides use top: 100%, right: 100% or left: 100%. The tooltip section writes all of it for the side and position you choose.
Not with either technique. The border trick and a polygon both end in a sharp point, and border-radius does nothing on a zero-size box. If you need a soft tip, draw the arrow as an inline SVG path with a round line join, or rotate a small square with rounded corners by 45 degrees and tuck it behind the box.
Use arbitrary values. The border version is w-0 h-0 with border-l-[10px], border-r-[10px] and border-b-[20px] plus border-l-transparent, border-r-transparent and a colored border-b. The clip-path version is a sized box with a background and an arbitrary property such as [clip-path:polygon(50%_0,0_100%,100%_100%)], with underscores for spaces. Both work in Tailwind 3 and 4.
The browser applies clip-path after the shadow is drawn and cuts everything outside the polygon, shadow included. Wrap the triangle in another element and put filter: drop-shadow on the wrapper, which shades the clipped shape. Turn on Drop shadow in the tool and the clip-path output adds that wrapper rule for you.
Yes to the link. Use ?dir= for the direction, ?w= and ?h= for the size, ?a= for the apex, ?c= and ?o= for color and opacity, and ?lock=, ?g=, ?c2=, ?sh=, ?side=, ?pos= and ?tt= for the rest, for example /css-triangle-generator/?dir=down&w=24&lock=equilateral&c=0d9488. Nothing is sent anywhere: the preview and the CSS are made in your browser.
Why We Built This CSS Triangle Generator
Tooltips, speech bubbles, carets and ribbons still need a triangle, and most of us still write it from memory: one colored border, two transparent ones, and a half-remembered rule about which is which. Get one side wrong and the arrow points the wrong way or floats off its box. We built a generator that writes the rule for all eight directions, keeps the apex and the sizes honest, and shows the result next to the clip-path version so you can choose with your eyes.
The two techniques are not interchangeable, so the page says plainly what each one can and cannot do: the border trick works everywhere but cannot hold a gradient, and clip-path can hold a gradient but cuts off its own shadow. The tooltip section writes the ::after rule with the right offsets for each side, and every output is in its shortest valid form, with a Tailwind version beside it. Everything runs in your browser, so nothing you design is uploaded.
The CSS Triangle Generator is part of RJL.io's collection of free developer tools. Cut any shape with the Clip Path Generator, add depth with the Box Shadow Generator, and build a fill with the Gradient Generator.