01What is CSS Triangle Generator?
You want a small arrow under a tooltip, and you don't want an SVG file or an icon font for six pixels of shape. The usual answer is the CSS border trick, and this generator writes it for you. Here's why it works. A box with zero width and zero height still draws its borders. Where two borders meet, the browser splits the corner along a diagonal, as the CSS Backgrounds and Borders spec describes for border joins. So if you color one border and make its neighbours transparent, the colored one shows up as a triangle. The tool gives you eight directions. The four straight ones (Up, Down, Left, Right) build an isosceles triangle. For Up, the bottom border carries the color at the full height, and the left and right borders are transparent at half the width each. Left and Right flip that: the height is split between the top and bottom borders and the width becomes the colored border. The four diagonal options (Up-Left, Up-Right, Down-Left, Down-Right) only need two borders, one colored and one transparent, which gives a right-angled corner triangle. A quick example. Pick the Tooltip arrow preset and you get Up, 16 by 8 px, color #1f2937. The output is a .triangle rule with width and height at 0, border-left and border-right at 8px solid transparent, and border-bottom at 8px solid #1f2937. That's a flat little arrow, twice as wide as it is tall. Width and Height are whole numbers. The fields read your input with parseInt, so typing 1.5 becomes 1. The inputs suggest a range of 1 to 500, but that's only a hint to the browser. An empty or zero field falls back to 1, and a bigger typed number isn't clamped. The Unit dropdown swaps the suffix between px, em and rem without converting the number. Odd sizes on straight directions produce half values such as 7.5px, which some screens render with soft edges. The color can come from the native picker or the text box. The text box accepts any CSS color string, such as red or an rgb() value, and passes it straight into the CSS. The picker itself only understands six-digit hex. The Preview always draws in pixels, even when you pick em or rem. So 2rem looks like 2px in the preview but will be 32px on a page with a 16px root font. Copy CSS puts the whole .triangle rule on your clipboard. Nothing you type leaves the page, because the CSS is built by a small function running in your tab.
Front-end developers reach for it when a tooltip, dropdown or nav item needs a small CSS arrow and an image would be overkill. The tool runs entirely in your browser, so your data never leaves your device.
02How to use CSS Triangle Generator
- Pick a preset (Tooltip arrow, Nav indicator or Dropdown arrow) or choose a Direction yourself
- Type whole numbers into Width and Height
- Choose px, em or rem in Unit
- Set the Color with the picker or type a CSS color into the text box
- Check the Preview, then click Copy CSS and rename .triangle to fit your code
03Worked examples
- Input:
Preset: Tooltip arrow (Up, width 16, height 8, #1f2937, px) - Result:
.triangle { width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 8px solid #1f2937; } - Up uses the bottom border for color. Each side border is half the width.
- Input:
Preset: Nav indicator (Right, width 12, height 20, #3b82f6, px) - Result:
.triangle { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 12px solid #3b82f6; } - For Left and Right, the height is split across top and bottom and the width becomes the colored border.
- Input:
Preset: Dropdown arrow (Down, width 20, height 12, #6b7280, px) - Result:
.triangle { width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 12px solid #6b7280; } - Input:
Direction: Left, width 10, height 15, color #000, px - Result:
.triangle { width: 0; height: 0; border-top: 7.5px solid transparent; border-bottom: 7.5px solid transparent; border-right: 10px solid #000; } - An odd height gives half-pixel borders. Use 14 or 16 for crisper edges.
- Input:
Direction: Down-Left, width 2, height 1, color red, rem - Result:
.triangle { width: 0; height: 0; border-bottom: 1rem solid red; border-right: 2rem solid transparent; } - Corner triangles use just two borders. The fields take whole numbers, so 1.5 would become 1.
- Input:
Direction: Up-Right, width 3, height 3, color #e11d48, em - Result:
.triangle { width: 0; height: 0; border-top: 3em solid #e11d48; border-left: 3em solid transparent; } - In em, the corner scales with the font size of the element it sits on.
04Common use cases
- Adding the pointer arrow under a tooltip or popover, sized to match its border radius
- Drawing a down caret next to a custom select or account menu button
- Marking the active link in a sidebar nav with a small right-pointing indicator
- Building a corner ribbon or folded-corner badge on a pricing card with a diagonal triangle
- Making speech-bubble tails for a chat UI prototype
- Teaching the border trick to a junior developer by toggling directions and watching the preview
05Tips
- Put the rule on ::before or ::after with position: absolute so the arrow hangs off the tooltip without an extra element.
- For a bordered arrow, stack two pseudo-elements: a slightly larger one in the border color behind a smaller one in the fill color.
- Use even widths for Up and Down (and even heights for Left and Right) to avoid half-pixel borders.
- The preview treats em and rem as px, so judge the shape there and check the real size in your page.
- If you need shadows or rounded tips, clip-path: polygon() or an inline SVG will do it, while border triangles can't.
06Related concepts
CSS border trick, pseudo-elements, tooltip arrow, clip-path, caret.
Frequently Asked Questions
What is CSS Triangle Generator?
CSS Triangle Generator is a free, browser-based developer tool on AIDToolStack. Generate CSS triangles with border trick It requires no installation or sign-up and works entirely in your browser.
Is CSS Triangle Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does CSS Triangle Generator store my data?
No. It runs in your browser; nothing is uploaded.