CSS Gradient Generator

This tool generates ready-to-use CSS linear-gradient code from two colours and a direction, with a live preview so you can see exactly how it will look. Gradients, smooth blends from one colour to another, are everywhere in modern web design: hero sections, buttons, cards, backgrounds and overlays all use them to add depth and visual interest that a flat colour cannot. Writing the CSS by hand is fiddly, though, because you have to remember the syntax, get the angle right, and guess at the colours without seeing the result. This generator removes all of that. You choose a start colour, an end colour, and the angle of the blend in degrees, where 0 points the gradient upward, 90 to the right, 180 downward and so on, and the calculator builds the CSS linear-gradient code and renders a live preview in those exact colours. Both the code and the preview update instantly as you adjust the colours or the angle, so you can dial in the look you want and then copy the finished CSS straight into your stylesheet. Use it to design backgrounds, buttons and cards, to experiment with colour combinations, or to learn how the linear-gradient syntax works. The generated code uses the standard CSS background property, so it works in every modern browser without prefixes. A few design tips: gradients between two closely related colours look subtle and professional, while strongly contrasting colours make a bold statement; a 135 degree diagonal is a popular, natural-looking choice; and for text laid over a gradient, make sure there is enough contrast across the whole blend for it to stay readable. Copy the code and paste it into any element's background.

-

Standard CSS linear-gradient, works in all modern browsers. Angle: 0deg = up, 90deg = right, 180deg = down. Copy the code into any element's background.

How it works

The two chosen colours and the angle are assembled into a CSS linear-gradient function, written as the background property. The angle sets the direction of the blend, measured clockwise from pointing straight up. The live preview applies the same gradient to a box so you can see the result exactly as a browser will render it.

Worked example

Choosing a blue start colour, a green end colour and an angle of 135 degrees produces the code background: linear-gradient(135deg, #2f6fb0, #28a745); The preview box fills with a diagonal blue-to-green blend running from the top-left to the bottom-right, the direction a 135 degree angle gives.

Related calculators

If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.

Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.

All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.

Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.

Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.

Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.

All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.

© 2019 to 2026 Calculate.co.nz. All rights reserved.