CSS Triangle Generator
Generate pure-CSS triangles in any direction.
.triangle {
width: 0;
height: 0;
border-right: 30px solid transparent;
border-bottom: 60px solid #00C8E0;
border-left: 30px solid transparent;
}The triangle is a zero-size element; one thick border carries the colour while the neighbouring borders stay transparent.
How to use CSS Triangle Generator
What this tool does
The CSS Triangle Generator produces a pure-CSS triangle using the long-standing
border trick — no SVG, no image file and no clip-path. You choose a direction,
a size and a colour, and the tool builds a complete CSS rule for a zero-size
element whose borders form the triangle. A live preview shows the exact shape,
and the rule is presented as copyable code. Everything is computed in your
browser.
The technique relies on how browsers render where two borders meet. Give an
element width: 0; height: 0 and thick borders, and each border is drawn as a
triangle that meets its neighbours along a diagonal. Colour one border and make
the adjacent ones transparent, and only that triangle is visible. It is a small
trick with a big payoff: a crisp, resolution-independent shape that weighs
nothing and inherits colour like any other border.
Use cases
The most common use is interface arrows. Tooltips, popovers and dropdown menus
almost always have a little pointer connecting them to the control that opened
them, and a CSS triangle is the standard way to draw it. Speech bubbles in chat
UIs use a triangle for the tail. Accordions, select-style menus and “show
more” toggles use a small caret that you can build here and rotate later.
Beyond arrows, triangles appear as ribbon ends, as breadcrumb separators, as
folded-corner effects on cards and as simple decorative accents in flat-design
layouts. The eight directions — four sides and four corners — cover pointers,
carets and right-angled corner wedges alike.
How to use it
- Pick a direction. The four side directions (up, down, left, right) make a symmetric triangle that points at a flat edge; the four corner directions make a right-angled triangle that fills a corner.
- Drag the Size slider to set how large the triangle is, in pixels. The preview resizes immediately.
- Choose a colour with the native picker, or type a hex value into the text field — the two stay in sync, and an invalid hex is flagged.
- Read the generated CSS — a complete
.trianglerule listing only the borders that matter. - Click Copy CSS to copy the rule, then paste it into your stylesheet and rename the selector to suit your markup.
- Use Reset to return to the defaults.
Tips
To attach a tooltip arrow, position the triangle element absolutely against the
tooltip’s edge — for a tooltip above a button, use a downward triangle on the
tooltip’s bottom edge so it points at the button. If you want the arrow colour
to follow the tooltip’s background automatically, set the coloured border with
currentColor and let the parent define the colour. For a thin caret rather
than a solid wedge, draw two triangles or use a rotated square with two
borders. Keep triangle sizes on a small, consistent scale across a project so
every pointer and caret feels related. Remember the element has no content area
— add padding or a wrapper if you need clickable space around the shape.
Related techniques
When you need a triangle that is part of a larger custom outline, or a shape with more than three sides, the Clip-Path Generator is the better tool — it can cut any polygon from an element. For rounded shapes and pill buttons, reach for the Border-Radius Generator instead. The border-triangle approach remains the lightest option for simple arrows and carets, and because its output is plain CSS it works in every framework, stylesheet and CSS-in-JS setup without any changes.
Frequently asked questions
How does a CSS triangle work without any SVG or images?
Why is one border value left out of the generated CSS?
How do I change the size of the triangle?
What are CSS triangles commonly used for?
Does this tool send my settings anywhere?
Related tools
Clip-Path Generator
Create CSS clip-path shapes visually.
Border-Radius Generator
Craft custom CSS border-radius shapes.
Box-Shadow Generator
Design CSS box-shadows with a live preview.
Gradient Generator
Build linear, radial, and conic CSS gradients.
CSS Transform Generator
Build CSS rotate, scale, and skew transforms.
Color Converter
Convert colors between HEX, RGB, HSL, HSV, and CMYK.