Gradients designed for light mode do not simply invert for dark mode.
Loading Gradient…
Generates gradients with colour values suited to dark backgrounds
Supports prefers-color-scheme: dark media query output
Visual preview on a dark background canvas
Explains dark mode colour adjustment principles
Drop the Gradient into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/gradient?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Gradient by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
Dark mode design is not about inverting light-mode colours. A vivid purple-to-pink gradient that communicates energy and brand vitality on a white page background becomes garish and overwhelming on a dark background because the lightness difference between the bright gradient and the surrounding dark UI chrome creates excessive visual contrast. Human visual systems adapt to overall ambient luminance: in a dark-mode interface, elements that would be considered normally vibrant in a light context become perceptually harsh because there is no bright environmental baseline to calibrate against. Effective dark mode gradients therefore use desaturated, medium-lightness colour values that provide visible colour interest against dark backgrounds without exceeding the moderate contrast threshold that comfortable dark mode reading requires. The practical adjustment is: reduce HSL saturation by 15 to 20 percentage points and reduce HSL lightness by 15 to 25 percentage points from the light-mode equivalent. The result is a gradient that reads as intentional, rich, and sophisticated against a dark background rather than neon, aggressive, or cheap.
The CSS technique for implementing dark mode gradients uses the @media (prefers-color-scheme: dark) media query. Define the default light-mode gradient outside the query, then override the gradient inside a dark-mode block. CSS custom properties are the most maintainable implementation: assign gradient colour values to :root variables such as --gradient-start and --gradient-end, then override those specific variable values inside the dark mode media query. The element rule background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end)) remains unchanged in the class or element selector, and the gradient adapts automatically to whichever variable values are in scope for the user's system colour scheme preference. This pattern keeps gradient definitions in one place, eliminates rule duplication, and makes updating both light and dark theme colours a simple variable substitution in the :root block.
FixTools generates dark-mode-appropriate gradient CSS including the primary gradient declaration and a @media (prefers-color-scheme: dark) override block. The tool also provides colour value recommendations calibrated specifically for dark background rendering, based on standard dark mode design principles. Copy the complete output and place it in your stylesheet. The dark mode override will activate automatically for users whose system preference is set to dark.
Dark mode design should also consider users who manually toggle themes via a button rather than relying solely on the system preference media query. The most common pattern is a data-theme attribute on the html or body element that a JavaScript toggle switches between values like "light" and "dark". CSS rules then target [data-theme="dark"] selectors instead of (or in addition to) the prefers-color-scheme media query. The cleanest integration uses CSS custom properties with values defined under :root for the light default, redefined under [data-theme="dark"] for the manual dark mode, and optionally also redefined under @media (prefers-color-scheme: dark) :root:not([data-theme="light"]) for system-preference-aware dark mode that the user has not manually overridden. This three-tier pattern respects both the user's manual selection and the system default, which is the behaviour most users intuitively expect from a theme toggle.
Configure a gradient for dark backgrounds. Example: background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)
Step-by-step guide to dark mode gradient css:
Open the CSS Gradient Generator
Navigate to the FixTools CSS Gradient Generator. For dark mode gradients, the key starting point is the preview background: ensure the preview canvas is set to dark mode so you can evaluate your gradient colours against a dark background as you configure them, not against the white default preview background.
Enable dark mode preview
Switch the preview background to a dark canvas in the tool settings. Evaluating gradient colours against a dark background is essential because colours that look vibrant and attractive on a white preview can appear garish, fluorescent, or low-quality on an actual dark interface background. The dark preview reflects the real rendering environment your gradient will inhabit.
Configure dark-appropriate colours
Choose dark navy, midnight blue, deep slate, or muted mid-tone colour values for your gradient stops. Keep HSL saturation in the 45 to 70% range rather than the 80 to 95% range typical of light-mode gradients. Avoid pure black as any stop: use tones like #0f172a or #1e293b that have enough colour character to produce a visible and interesting directional shift against the surrounding dark UI.
Copy the gradient with media query output
Copy the complete output including both the default gradient rule and the @media (prefers-color-scheme: dark) override block. Place both blocks in your stylesheet. The default rule applies in light mode; the dark mode block overrides it automatically for users whose system preference is set to dark, without requiring any JavaScript or manual class toggling.
Common situations where this approach makes a real difference:
Dark mode hero section for a developer tool
A developer tooling product page defaults to dark mode because its target audience of software engineers strongly prefers dark interfaces. The hero section uses a subtle three-stop gradient: #0d1117 at 0%, #161b22 at 50%, and #1f2937 at 100%. The near-identical dark tones create a perceptible depth shift that makes the hero feel dimensional rather than flat, without any colour that reads as harsh or bright on the dark canvas. Headline text uses rgba(255,255,255,0.9) rather than pure white to soften glare and reduce eye strain for extended sessions.
System-preference-aware pricing section
A SaaS pricing page must look equally polished in both light and dark mode because it serves a mixed audience across operating system preferences. In light mode, the featured plan card uses a vivid indigo-to-purple gradient at HSL(240, 80%, 60%) to HSL(280, 75%, 55%). The CSS custom property pattern switches these values inside a dark mode media query to a desaturated deep navy-to-dark-violet pair at HSL(240, 45%, 28%) to HSL(280, 40%, 25%). The hue identity of the brand is preserved while the saturation and lightness are adjusted to the dark mode context.
Dashboard sidebar gradient accent
An analytics dashboard has a left navigation sidebar in dark mode and needs a top-edge gradient accent to add brand colour without overwhelming the sidebar menu items. The gradient runs from dark teal (#0d4a4a) at the top to transparent using the rgba correction technique, spanning the first 80px of the sidebar height. The teal is derived from the light-mode brand green but with HSL lightness reduced from 65% to 40% and saturation from 80% to 55%, keeping the brand connection visible on the dark surface without the green appearing fluorescent or unpleasantly bright against the dark sidebar background.
Dark mode card component with gradient depth
Data cards in a dark mode analytics dashboard use a top-to-bottom gradient from #1e293b at the top to #0f172a at the bottom, applied at height: 180px per card. The gradient simulates natural top-down lighting by making the top of the card surface slightly lighter than the bottom, which aligns with how humans intuitively perceive illuminated objects. Cards are visually distinct from the #050a11 page background, creating a clear figure-ground separation that makes the dashboard layout easy to parse even at a distance or in low-ambient-light environments.
Use this when you are building a dark-mode UI or designing a site that supports prefers-color-scheme: dark and need gradients that look polished on dark backgrounds.
Get better results with these expert suggestions:
Reduce saturation by 15 to 20 points for dark mode gradients
Vivid, high-saturation gradients on dark backgrounds produce an unpleasant neon-on-black effect that signals low quality and visual immaturity to experienced dark mode users. Dropping HSL saturation by 15 to 20 percentage points while keeping the hue constant preserves the colour identity and brand recognisability of the gradient while toning it down to a comfortable level for dark contexts. A brand blue at HSL(220, 90%, 60%) in light mode becomes a calmer and more sophisticated HSL(220, 70%, 45%) in dark mode, which reads as considered and polished against a near-black background.
Use dark navy or deep slate tones for gradient endpoints
Dark mode gradients that use near-pure black (#0a0a0a or #111111) as one of the colour stops produce gradients that are barely distinguishable from a flat black background, because there is insufficient lightness contrast between the stop and the surrounding UI. Use dark navy (#0f172a), deep slate (#1e293b), midnight blue (#1a1a2e), or deep ocean (#0a192f) as the darker endpoint. These tones have enough colour character and lightness to produce a visible and interesting directional shift even against dark backgrounds.
Define dark and light gradient variants as CSS custom properties
Place gradient colour values in :root CSS custom properties with descriptive names like --g-start and --g-end. Override only these variable values inside the dark mode media query: :root { --g-start: #667eea; --g-end: #764ba2; } @media (prefers-color-scheme: dark) { :root { --g-start: #2d3561; --g-end: #3b1f5e; } }. The element rule background: linear-gradient(135deg, var(--g-start), var(--g-end)) stays unchanged. Updating both themes in the future requires only editing variable values in the :root block, not searching through every gradient rule across the stylesheet.
Add a subtle noise texture over dark gradients for depth
Flat dark gradients can look visually muddy or indistinct on OLED screens because very dark colours occupy a narrow perceptual lightness range. Layering a semi-transparent noise texture over the dark gradient using a second background layer adds micro-contrast that makes the gradient surface feel tactile and three-dimensional. Keep the noise opacity very low, between 4% and 8%, so it adds texture without obscuring or competing with the underlying gradient colours. SVG-based noise patterns encoded as base64 data URIs are the most portable method for this technique.
More use-case guides for the same tool:
Open the full Gradient — free, no account needed, works on any device.
Open Gradient →Free · No account needed · Works on any device