{"id":2828,"date":"2024-06-26T07:38:28","date_gmt":"2024-06-26T13:38:28","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=2828"},"modified":"2024-06-26T07:40:10","modified_gmt":"2024-06-26T13:40:10","slug":"text-reveal-with-conic-gradient","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/text-reveal-with-conic-gradient\/","title":{"rendered":"A Text-Reveal Effect Using conic-gradient() in CSS"},"content":{"rendered":"\n<p>Part of the appeal of the web as a design medium is the movement. The animations, transitions, and interactivity. Text can be done in any medium, but text that <em>reveals itself<\/em> over time in an interesting way? That&#8217;s great for the web. Think posters, galleries, banners, advertisements, or even something as small as spoiler-reveal effects, &#8220;reveal&#8221; animations can be entirely delightful. In this article, we\u2019ll look at one fairly simple method for doing this with CSS. <\/p>\n\n\n\n<p>Here\u2019s the outcome, incorporating a play button to show you it can be done via user interaction:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/z1xS4PmR.gif?resize=1024%2C576&#038;ssl=1\" alt=\"\" class=\"wp-image-2830\" style=\"width:565px;height:auto\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/z1xS4PmR.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/z1xS4PmR.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/z1xS4PmR.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/div>\n\n\n<p>This is achieved with the help of \u201c<em>masking<\/em>\u201d and perfectly placed&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/gradient\/conic-gradient\">conic-gradient()<\/a><\/code>. <a href=\"https:\/\/caniuse.com\/css-conic-gradients\">The browser support for conic gradients<\/a> is fine, but we&#8217;re also going to be using CSS&#8217; <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@property\">@property<\/a><\/code> here which isn&#8217;t in stable Firefox yet, but is in Firefox Nightly.<\/p>\n\n\n\n<p class=\"learn-more\"><strong>Note<\/strong>: Masking is a graphic technique where portion of a graphic or image is hidden based on the graphic or image layered over and\/or under it, based on either the alpha channel or the light\/darkness of masking image.<\/p>\n\n\n\n<p>In our example, the&nbsp;<em>masking<\/em>&nbsp;is done using&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/blend-mode\">CSS Blend Mode<\/a>. I\u2019ll mention later why this is the method I\u2019d chosen instead of CSS Mask (the&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/mask-image\">mask-image<\/a><\/code>&nbsp;property).<\/p>\n\n\n\n<p>Let\u2019s get started with the HTML. Some black text on a white background is a good place to start. This is technically our \u201cmask\u201d.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>Marasmius rotula is... <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">p<\/span> {\n  <span class=\"hljs-attribute\">background<\/span>: white;\n  <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">34px<\/span>;\n  <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">42px<\/span>;\n  <span class=\"hljs-attribute\">text-align<\/span>: justify;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?resize=1024%2C619&#038;ssl=1\" alt=\"\" class=\"wp-image-2832\" style=\"width:610px;height:auto\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?resize=1024%2C619&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?resize=300%2C181&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?resize=768%2C464&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?resize=1536%2C928&amp;ssl=1 1536w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/XU95bg4O.png?w=1596&amp;ssl=1 1596w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/div>\n\n\n<p>A container element is added around the text to serve as the graphic to be shown <em>through<\/em> the mask\/text. Also, a CSS variable is used in the container element to assign the&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/line-height\">line-height<\/a><\/code>. This variable will later be used in the gradient.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">section<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"text\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>Marasmius rotula...<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">section<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">420px<\/span>;\n<\/span><\/span><mark class='shcb-loc'><span>  <span class=\"hljs-attribute\">--lH<\/span>: <span class=\"hljs-number\">42px<\/span>; <span class=\"hljs-comment\">\/* line height *\/<\/span> \n<\/span><\/mark><span class='shcb-loc'><span>  \n<\/span><\/span><span class='shcb-loc'><span>  p {\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">background<\/span>: white;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">34px<\/span>;\n<\/span><\/span><mark class='shcb-loc'><span>    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-built_in\">var<\/span>(--lH);\n<\/span><\/mark><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">text-align<\/span>: justify;\n<\/span><\/span><span class='shcb-loc'><span>  }\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, we write up a&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/gradient\/conic-gradient\">conic-gradient()<\/a><\/code>&nbsp;as the&nbsp;<code>background<\/code>&nbsp;for the&nbsp;<code>&lt;section&gt;<\/code>&nbsp;container, with the gradient\u2019s height same as the para\u2019s&nbsp;<code>line-height<\/code>, and set to repeat for each line of text. The gradient should look like an arrow (triangular at the tip) passing through the text.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">420px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">--lH<\/span>: <span class=\"hljs-number\">42px<\/span>; <span class=\"hljs-comment\">\/* line height *\/<\/span> \n<\/span><\/span><mark class='shcb-loc'><span>  <span class=\"hljs-attribute\">background<\/span>: repeat-y left\/<span class=\"hljs-number\">100%<\/span> <span class=\"hljs-built_in\">var<\/span>(--lH) <span class=\"hljs-built_in\">conic-gradient<\/span>(white <span class=\"hljs-number\">265deg<\/span>, red <span class=\"hljs-number\">269deg<\/span> <span class=\"hljs-number\">271deg<\/span>, white <span class=\"hljs-number\">275deg<\/span>), white;\n<\/span><\/mark><span class='shcb-loc'><span>  \n<\/span><\/span><span class='shcb-loc'><span>  p {\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">background<\/span>: white;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">34px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-built_in\">var<\/span>(--lH);\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">text-align<\/span>: justify;\n<\/span><\/span><span class='shcb-loc'><span>  }\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>We won\u2019t see anything yet since the \u201cblack text with white background\u201d,&nbsp;<code>&lt;p&gt;<\/code>, is blocking the gradient behind it. However, the gradient looks like this:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"728\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?resize=1024%2C728&#038;ssl=1\" alt=\"\" class=\"wp-image-2833\" style=\"width:500px;height:auto\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?resize=1024%2C728&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?resize=300%2C213&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?resize=768%2C546&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?w=1296&amp;ssl=1 1296w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/div>\n\n\n<p>We&#8217;ll now turn the gradient into an animation, where it grows from zero width to however much width is needed for it to cover the entire text. For the moment, let\u2019s make this transition animation to take place when we <code>hover<\/code> the cursor on the text.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-code-table\"><mark class='shcb-loc'><span><span class=\"hljs-keyword\">@property<\/span> --n {\n<\/span><\/mark><mark class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">syntax<\/span>: \"&lt;<span class=\"hljs-selector-tag\">length-percentage<\/span>&gt;\";\n<\/span><\/mark><mark class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">inherits<\/span>: <span class=\"hljs-selector-tag\">false<\/span>;\n<\/span><\/mark><mark class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">initial-value<\/span>: 0%;\n<\/span><\/mark><mark class='shcb-loc'><span>}\n<\/span><\/mark><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">420px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">--lH<\/span>: <span class=\"hljs-number\">42px<\/span>; <span class=\"hljs-comment\">\/* line height *\/<\/span> \n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">background<\/span>: \n<\/span><\/span><span class='shcb-loc'><span>  repeat-y left\/<span class=\"hljs-built_in\">var<\/span>(--n) <span class=\"hljs-built_in\">var<\/span>(--lH) <span class=\"hljs-built_in\">conic-gradient<\/span>(white <span class=\"hljs-number\">265deg<\/span>, red <span class=\"hljs-number\">269deg<\/span> <span class=\"hljs-number\">271deg<\/span>, white <span class=\"hljs-number\">275deg<\/span>), white;\n<\/span><\/span><span class='shcb-loc'><span>  \n<\/span><\/span><span class='shcb-loc'><span>  p {\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">background<\/span>: white;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">34px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-built_in\">var<\/span>(--lH);\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">text-align<\/span>: justify;\n<\/span><\/span><span class='shcb-loc'><span>  }\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span><span class=\"hljs-selector-pseudo\">:hover<\/span> {\n<\/span><\/mark><mark class='shcb-loc'><span>  <span class=\"hljs-attribute\">--n<\/span>: <span class=\"hljs-number\">340%<\/span>;\n<\/span><\/mark><mark class='shcb-loc'><span>  <span class=\"hljs-attribute\">transition<\/span>: --n linear <span class=\"hljs-number\">2s<\/span>;\n<\/span><\/mark><mark class='shcb-loc'><span>}\n<\/span><\/mark><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The&nbsp;<code>--n<\/code>&nbsp;custom property is used to assign the size of the gradient. Its initial value is&nbsp;<code>0%<\/code>, which increases with a&nbsp;<code>transition<\/code>&nbsp;effect when the text is hovered, and hence the gradient grows in width.<\/p>\n\n\n\n<p>We still haven\u2019t&nbsp;<em>masked<\/em>&nbsp;our example. So, once again, only the text will be visible. Let me show you how the gradient animates, separately, below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/eAHC7gng.gif?resize=1024%2C576&#038;ssl=1\" alt=\"\" class=\"wp-image-2834\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/eAHC7gng.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/eAHC7gng.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/eAHC7gng.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p class=\"learn-more\"><strong>Note<\/strong>:&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@property\">@property<\/a><\/code>&nbsp;creates a custom property that has a <em>known type<\/em>, hence the property value can be animated. The custom property may not have been able to be animated otherwise.<\/p>\n\n\n\n<p>Let\u2019s now drop the blend mode (the&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/mix-blend-mode\">mix-blend-mode<\/a><\/code>&nbsp;property) into the&nbsp;<code>&lt;p&gt;<\/code>&nbsp;element to finally see the effect.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">@property<\/span> --n {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">syntax<\/span>: \"\";\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">inherits<\/span>: <span class=\"hljs-selector-tag\">false<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-selector-tag\">initial-value<\/span>: 0%;\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">420px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">--lH<\/span>: <span class=\"hljs-number\">42px<\/span>; <span class=\"hljs-comment\">\/* line height *\/<\/span> \n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">background<\/span>: \n<\/span><\/span><span class='shcb-loc'><span>  repeat-y left\/<span class=\"hljs-built_in\">var<\/span>(--n) <span class=\"hljs-built_in\">var<\/span>(--lH) <span class=\"hljs-built_in\">conic-gradient<\/span>(white <span class=\"hljs-number\">265deg<\/span>, red <span class=\"hljs-number\">269deg<\/span> <span class=\"hljs-number\">271deg<\/span>, white <span class=\"hljs-number\">275deg<\/span>), white;\n<\/span><\/span><span class='shcb-loc'><span>  \n<\/span><\/span><span class='shcb-loc'><span>  p {\n<\/span><\/span><mark class='shcb-loc'><span>    <span class=\"hljs-attribute\">mix-blend-mode<\/span>: screen;\n<\/span><\/mark><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">background<\/span>: white;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">34px<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-built_in\">var<\/span>(--lH);\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attribute\">text-align<\/span>: justify;\n<\/span><\/span><span class='shcb-loc'><span>  }\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">section<\/span><span class=\"hljs-selector-class\">.text<\/span><span class=\"hljs-selector-pseudo\">:hover<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">--n<\/span>: <span class=\"hljs-number\">340%<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">transition<\/span>: --n linear <span class=\"hljs-number\">2s<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For the sake of operability, instead of on text hover, I\u2019ll move the animation to take place with user controls,&nbsp;<em>Play<\/em>&nbsp;and&nbsp;<em>Reset<\/em>. Here\u2019s the final output:<\/p>\n\n\n\n<div class=\"wp-block-cp-codepen-gutenberg-embed-block cp_embed_wrapper\"><iframe id=\"cp_embed_NWVwgdO\" src=\"\/\/codepen.io\/anon\/embed\/NWVwgdO?height=450&amp;theme-id=47434&amp;slug-hash=NWVwgdO&amp;default-tab=result\" height=\"450\" scrolling=\"no\" frameborder=\"0\" allowfullscreen allowpaymentrequest name=\"CodePen Embed NWVwgdO\" title=\"CodePen Embed NWVwgdO\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/div>\n\n\n\n<p>The reason we didn&#8217;t use&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/mask-image\">mask-image<\/a><\/code>, as I mentioned before is because Safari doesn\u2019t render the output if I use multiple gradient images (on top of the&nbsp;<code>conic-gradient()<\/code>), and also has a blotchy implementation of&nbsp;<code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/box-decoration-break\">box-decoration-break<\/a><\/code>&nbsp;during animation, both of which are important to work correctly for the effect I wanted to achieve.<\/p>\n\n\n\n<p>That said, here\u2019s&nbsp;<a href=\"https:\/\/codepen.io\/rpsthecoder\/full\/mdYXWXj\">a Pen<\/a>&nbsp;that uses&nbsp;<code>mask-image<\/code>&nbsp;and&nbsp;<code>box-decoration-break<\/code>, in case you want to learn how to go about it and get some ideas on approaching any alternative methods. At the time of writing this article, it\u2019s best to view that in Chrome.<\/p>\n\n\n\n<p>Here&#8217;s another example that shows off how this effect might be used in a real-world context, revealing the text of different &#8220;tabs&#8221; as you navigate between tags. <\/p>\n\n\n\n<div class=\"wp-block-cp-codepen-gutenberg-embed-block cp_embed_wrapper\"><iframe id=\"cp_embed_GRaQrXv\" src=\"\/\/codepen.io\/anon\/embed\/GRaQrXv?height=450&amp;theme-id=47434&amp;slug-hash=GRaQrXv&amp;default-tab=result\" height=\"450\" scrolling=\"no\" frameborder=\"0\" allowfullscreen allowpaymentrequest name=\"CodePen Embed GRaQrXv\" title=\"CodePen Embed GRaQrXv\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/div>\n\n\n\n<p>For design variants, play with different colors, and number and&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/CSS_images\/Using_CSS_gradients\">kind of gradients<\/a>. Let me know what you come up with! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article explores creating a typographic effect that &#8220;reveals&#8221; text in an interesting animated way. <\/p>\n","protected":false},"author":20,"featured_media":2833,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[192,7,39],"class_list":["post-2828","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","tag-conic-gradient","tag-css","tag-typography"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/06\/tegqoID6.png?fit=1296%2C922&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=2828"}],"version-history":[{"count":14,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2828\/revisions"}],"predecessor-version":[{"id":2862,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2828\/revisions\/2862"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/2833"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=2828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=2828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=2828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}