CSS-Tricks on Flywheel

Post pobrano z: CSS-Tricks on Flywheel

I first heard of Flywheel through their product Local, which is a native app for working on WordPress sites. If you ask around for what people use for that kind of work, you’ll get all sorts of answers, but an awful lot of very strong recommendations for Local. I’ve become one of them! We ultimately did a sponsored post for Local, but that’s based on the fact that now 100% of my local WordPress development work is done using it and I’m very happy with it.

Now I’ve taken the next step and moved all my production sites to Flywheel hosting!

Full disclosure here, Flywheel is now a sponsor of CSS-Tricks. I’ve been wanting to work with them for a while. I’ve been out to visit them in Omaha! (👋 at Jamie, Christi, Karissa, and everybody I’ve worked with over there.) Part of our deal includes the hosting. But I was a paying customer and user of Flywheel before this on some sites, and my good experiences there are what made me want to get this sponsorship partnership cooking! There has been big recent news that Flywheel was acquired by WP Engine. I’m also a fan of WP Engine, being also a premium WordPress host that has done innovative things with hosting, so I’m optimistic that a real WordPress hosting powerhouse is being formed and I’ve got my sites in the right place.

Developing on Local is a breeze

It feels like a breath of fresh air to me, as running all the dev dependencies for WordPress has forever been a bit of a pain in the butt. Sometimes you have it going fine, but then something breaks in the most inscrutable possible way and it takes forever to get going again. Whatever, you know what I mean. At this point, I’ve been running Local for over a year and have had almost no issues with it.

There are all kinds of features worth checking out here. Here’s one that is very likely useful to bigger teams. Say you have a Flywheel account with a bunch of production sites on it. Then a new person starts working with you and they have their own computer. You connect Local to Flywheel, and you can pull down the site and have it ready to work on. That’s pretty sweet.

Local doesn’t lock you into anything either. You can use Local for local development and literally use nothing else. Local can push a site up to Flywheel hosting too, which I’ve found to be mighty useful particularly for that first deployment of a new site, but you don’t have to use that if you don’t want. I’ll cover more about workflow below.

Other features that I find worthy of note:

  • Spinning up a new site takes just a second. A quick walkthrough through a wizard where they ask you some login details but otherwise offer smart-but-customizable defaults.
  • Dealing with HTTPS locally is easy. It will create a certificate for you and trust it locally with one click.
  • You can flip on „Live Link”, which uses ngrok to create a live, sharable URL to your localhost site. Great for temporarily showing a client or co-worker something without having to move anything.
  • One click to pop open the database in Sequel Pro, my favorite free database tool. Much easier than trying to spin up phpMyAdmin or whatever on the web to manage from there.

Flywheel’s Dashboard is so clear

I love the simple UI of Local, and I really like how that same design and spirit carries over into the Flywheel hosting dashboard.

There are so many things the dashboard makes easy:

  • You need an SSL cert? Click some buttons.
  • Wanna force HTTPS? Flip a switch.
  • Wanna convert the site to Multisite? Hit a button.
  • Need to edit the database? There is a UI around it built in.
  • Want a CDN? Toggle a thing.
  • Need to invite a collaborator on a site? Go for it.
  • Need a backup? There are in there, download it or restore to that point.

It’s a big deal when everything is simple and works. It means you aren’t burning hours fighting with tools and you can use them doing work that pushes you forward.

Workflow

When I set up my new CSS-Tricks workflow, I had Flywheel move the site for me (thanks gang!) (no special treatment either, they’ll do that for anybody).

I’ve got Local already, so my local development process is the same. But I needed to update my deployment workflow for the new hosting. Local can push a site up to Flywheel hosting, but it just zips everything up and sends it all up. Great for first deployment but not perfect for tiny little changes like 95% of the work I do. There is a new Local for Teams feature, which uses what they call MagicSync for deployment, which only deploys changed files. That’s very cool, but I like working with a Git-based system, where ultimately merges to master are what trigger deployment of the changed files.

For years I’ve used Beanstalk for Git-based deployment over SFTP. I still am using Beanstalk for many sites and think it’s a great choice, but Beanstalk has the limitation that the Git-repo is basically a private Git repo hosted by Beanstalk itself.

During this change, I needed to switch up what the root of the repo is (more on that in a second) so I wanted to create a new repo. I figured rather than doing that on Beanstalk, I’d make a private GitHub repo and set up deployment from there. There are services like DeployHQ and DeployBot that will work well for that, but I went with Buddy, which has a really really nice UI for managing all this stuff, and is capable of much more than just deployment should I ultimately need that.

Regarding the repo itself, one thing that I’ve always done with my WordPress sites is just make the repo the whole damn thing starting at the root. I think it’s just a legacy/comfort thing. I had some files at the root I wanted to deploy along with everything else and that seemed like the easiest way. In WordPress-land, this isn’t usually how it’s done. It’s more common to have the /wp-content/ folder be the root of the repo, as those are essentially the only files unique to your installation. I can imagine setups where even down to individual themes are repos and deployed alone.

I figured I’d get on board with a more scoped deployment, but also, I didn’t have much of a choice. Flywheel literally locks down all WordPress core files, so if your deployment system tries to override them, it will just fail. That actually sounds great to me. There is no reason anyone from the outside should alter those files, might as well totally remove it as an attack vector. Flywheel itself keeps the WordPress version up to date. So I made a new repo with /wp-content/ at the root, and I figured I’d make it on GitHub instead just because that’s such an obvious hub of developer activity and keeps my options wide open for deployment choices.

Maybe I’ll open source it all one day when I’ve had a chance to comb through it.

For the same kind of spiritual reasons, during the the move, I moved the DNS over to Cloudflare. This gives me control over DNS from a third-party so it’s easy for me to point things where I need them. Kind of a decentralization of concerns. That’s not for everyone, but it’s great for me on this project. While now I might suffer from Cloudflare outages (rare, but it literally just happened), I benefit from all sorts of additional security and performance that Cloudflare can provide.

So the workflow is Local > GitHub > Buddy > Flywheel.

And the hosting is Cloudflare > Flywheel with image assets on Cloudinary.

And I’ve got backups from both Flywheel and Jetpack/VaultPress.

The post CSS-Tricks on Flywheel appeared first on CSS-Tricks.

Five Methods for Five-Star Ratings

Post pobrano z: Five Methods for Five-Star Ratings

In the world of likes and social statistics, reviews are very important method for leaving feedback. Users often like to know the opinions of others before deciding on items to purchase themselves, or even articles to read, movies to see, or restaurants to dine.

Developers often struggle with with reviews — it is common to see inaccessible and over-complicated implementations. Hey, CSS-Tricks has a snippet for one that’s now bordering on a decade.

Let’s walk through new, accessible and maintainable approaches for this classic design pattern. Our goal will be to define the requirements and then take a journey on the thought-process and considerations for how to implement them.

Scoping the work

Did you know that using stars as a rating dates all the way back to 1844 when they were first used to rate restaurants in Murray’s Handbooks for Travellers — and later popularized by Michelin Guides in 1931 as a three-star system? There’s a lot of history there, so no wonder it’s something we’re used to seeing!

There are a couple of good reasons why they’ve stood the test of time:

  1. Clear visuals (in the form of five hollow or filled stars in a row)
  2. A straightforward label (that provides an accessible description, like aria-label)

When we implement it on the web, it is important that we focus meeting both of those outcomes.

It is also important to implement features like this in the most versatile way possible. That means we should reach for HTML and CSS as much as possible and try to avoid JavaScript where we can. And that’s because:

  1. JavaScript solutions will always differ per framework. Patterns that are typical in vanilla JavaScript might be anti-patterns in frameworks (e.g. React prohibits direct document manipulation).
  2. Languages like JavaScript evolve fast, which is great for community, but not so great articles like this. We want a solution that’s maintainable and relevant for the long haul, so we should base our decisions on consistent, stable tooling.

Methods for creating the visuals

One of the many wonderful things about CSS is that there are often many ways to write the same thing. Well, the same thing goes for how we can tackle drawing stars. There are five options that I see:

  • Using an image file
  • Using a background image
  • Using SVG to draw the shape
  • Using CSS to draw the shape
  • Using Unicode symbols

Which one to choose? It depends. Let’s check them all out.

Method 1: Using an image file

Using images means creating elements — at least 5 of them to be exact. Even if we’re calling the same image file for each star in a five-star rating, that’s five total requests. What are the consequences of that?

  1. More DOM nodes make document structure more complex, which could cause a slower page paint. The elements themselves need to render as well, which means either the server response time (if SSR) or the main thread generation (if we’re working in a SPA) has to increase. That doesn’t even account for the rendering logic that has to be implemented.
  2. It does not handle fractional ratings, say 2.3 stars out of 5. That would require a second group of duplicated elements masked with clip-path on top of them. This increases the document’s complexity by a minimum of seven more DOM nodes, and potentially tens of additional CSS property declarations.
  3. Optimized performance ought to consider how images are loaded and implementing something like lazy-loading) for off-screen images becomes increasingly harder when repeated elements like this are added to the mix.
  4. It makes a request, which means that caching TTLs should be configured in order to achieve an instantaneous second image load. However, even if this is configured correctly, the first load will still suffer because TTFB awaits from the server. Prefetch, pre-connect techniques or the service-worker should be considered in order to optimize the first load of the image.
  5. It creates minimum of five non-meaningful elements for a screen reader. As we discussed earlier, the label is more important than the image itself. There is no reason to leave them in the DOM because they add no meaning to the rating — they are just a common visual.
  6. The images might be a part of manageable media, which means content managers will be able to change the star appearance at any time, even if it’s incorrect.
  7. It allows for a versatile appearance of the star, however the active state might only be similar to the initial state. It’s not possible to change the image src attribute without JavaScript and that’s something we’re trying to avoid.

Wondering how the HTML structure might look? Probably something like this:

<div class="Rating" aria-label="Rating of this item is 3 out of 5">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star">
  <img src="/static/assets/star.png" class="Rating--Star">
</div>

In order to change the appearance of those stars, we can use multiple CSS properties. For example:

.Rating--Star {
  filter: grayscale(100%); // maybe we want stars to become grey if inactive
  opacity: .3; // maybe we want stars to become opaque
}

An additional benefit of this method is that the <img> element is set to inline-block by default, so it takes a little bit less styling to position them in a single line.

Accessibility: ★★☆☆☆
Management: ★★★★☆
Performance: ★☆☆☆☆
Maintenance: ★★★★☆
Overall: ★★☆☆☆

Method 2: Using a background image

This was once a fairly common implementation. That said, it still has its pros and cons.

For example:

  1. Sure, it’s only a single server request which alleviates a lot of caching needs. At the same time, we now have to wait for three additional events before displaying the stars: That would be (1) the CSS to download, (2) the CSSOM to parse, and (3) the image itself to download.
  2. It’s super easy to change the state of a star from empty to filled since all we’re really doing is changing the position of a background image. However, having to crack open an image editor and re-upload the file anytime a change is needed in the actual appearance of the stars is not the most ideal thing as far as maintenance goes.
  3. We can use CSS properties like background-repeat property and clip-path to reduce the number of DOM nodes. We could, in a sense, use a single element to make this work. On the other hand, it’s not great that we don’t technically have good accessible markup to identify the images to screen readers and have the stars be recognized as inputs. Well, not easily.

In my opinion, background images are probably best used complex star appearances where neither CSS not SVG suffice to get the exact styling down. Otherwise, using background images still presents a lot of compromises.

Accessibility: ★★★☆☆
Management: ★★★★☆
Performance: ★★☆☆☆
Maintenance: ★★★☆☆
Overall: ★★★☆☆

Method 3: Using SVG to draw the shape

SVG is great! It has a lot of the same custom drawing benefits as raster images but doesn’t require a server call if it’s inlined because, well, it’s simply code!

We could inline five stars into HTML, but we can do better than that, right? Chris has shown us a nice approach that allows us to provide the SVG markup for a single shape as a <symbol> and call it multiple times with with <use>.

<!-- Draw the star as a symbol and remove it from view -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="star" viewBox="214.7 0 182.6 792">
    <!-- <path>s and whatever other shapes in here -->  
  </symbol>
</svg>
    
<!-- Then use anywhere and as many times as we want! -->
<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

What are the benefits? Well, we’re talking zero requests, cleaner HTML, no worries about pixelation, and accessible attributes right out of the box. Plus, we’ve got the flexibility to use the stars anywhere and the scale to use them as many times as we want with no additional penalties on performance. Score!

The ultimate benefit is that this doesn’t require additional overhead, either. For example, we don’t need a build process to make this happen and there’s no reliance on additional image editing software to make further changes down the road (though, let’s be honest, it does help).

Accessibility: ★★★★★
Management: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★★★☆
Overall: ★★★★☆

Method 4: Using CSS to draw the shape

This method is very similar to background-image method, though improves on it by optimizing drawing the shape with CSS properties rather than making a call for an image. We might think of CSS as styling elements with borders, fonts and other stuff, but it’s capable of producing ome pretty complex artwork as well. Just look at Diana Smith’s now-famous “Francine” portrait.

Francine, a CSS replica of an oil painting done in CSS by Diana Smith (Source)

We’re not going to get that crazy, but you can see where we’re going with this. In fact, there’s already a nice demo of a CSS star shape right here on CSS-Tricks.

See the Pen
Five stars!
by Geoff Graham (@geoffgraham)
on CodePen.

Or, hey, we can get a little more crafty by using the clip-path property to draw a five-point polygon. Even less CSS! But, buyer beware, because your cross-browser support mileage may vary.

See the Pen
5 Clipped Stars!
by Geoff Graham (@geoffgraham)
on CodePen.

Accessibility: ★★★★★
Manangement: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★☆☆☆
Overall: ★★★☆☆

Method 5: Using Unicode symbols

This method is very nice, but very limited in terms of appearance. Why? Because the appearance of the star is set in stone as a Unicode character. But, hey, there are variations for a filled star (★) and an empty star (☆) which is exactly what we need!

Unicode characters are something you can either copy and paste directly into the HTML:

See the Pen
Unicode Stars!
by Geoff Graham (@geoffgraham)
on CodePen.

We can use font, color, width, height, and other properties to size and style things up a bit, but not a whole lot of flexibility here. But this is perhaps the most basic HTML approach of the bunch that it almost seems too obvious.

Instead, we can move the content into the CSS as a pseudo-element. That unleashes additional styling capabilities, including using custom properties to fill the stars fractionally:

See the Pen
Tiny but accessible 5 star rating
by Fred Genkin (@FredGenkin)
on CodePen.

Let’s break this last example down a bit more because it winds up taking the best benefits from other methods and splices them into a single solution with very little drawback while meeting all of our requirements.

Let’s start with HTML. there’s a single element that makes no calls to the server while maintaining accessibility:

<div class="stars" style="--rating: 2.3;" aria-label="Rating of this product is 2.3 out of 5."></div>

As you may see, the rating value is passed as an inlined custom CSS property (--rating). This means there is no additional rendering logic required, except for displaying the same rating value in the label for better accessibility.

Let’s take a look at that custom property. It’s actually a conversion from a value value to a percentage that’s handled in the CSS using the calc() function:

--percent: calc(var(--rating) / 5 * 100%);

I chose to go this route because CSS properties — like width and linear-gradient — do not accept <number> values. They accept <length> and <percentage> instead and have specific units in them, like % and px, em. Initially, the rating value is a float, which is a <number> type. Using this conversion helps ensure we can use the values in a number of ways.

Filling the stars may sound tough, but turns out to be quite simple. We need a linear-gradient background to create hard color stops where the gold-colored fill should end:

background: linear-gradient(90deg,
  var(--star-background) var(--percent), 
  var(--star-color) var(--percent)
);

Note that I am using custom variables for colors because I want the styles to be easily adjustable. Because custom properties are inherited from the parent elements styles, you can define them once on the :root element and then override in an element wrapper. Here’s what I put in the root:

:root {
  --star-size: 60px;
  --star-color: #fff;
  --star-background: #fc0;
}

The last thing I did was clip the background to the shape of the text so that the background gradient takes the shape of the stars. Think of the Unicode stars as stencils that we use to cut out the shape of stars from the background color. Or like a cookie cutters in the shape of stars that are mashed right into the dough:

-webkit-background-clip: text;
-webkit-text-fill-color: transparent;

The browser support for background clipping and text fills is pretty darn good. IE11 is the only holdout.

Accessibility: ★★★★★
Management: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★★★★
Overall: ★★★★★

Final thoughts

Image Files Background Image SVG CSS Shapes Unicode Symbols
Accessibility ★★☆☆☆ ★★★☆☆ ★★★★★ ★★★★★ ★★★★★
Management ★★★★☆ ★★★★☆ ★★☆☆☆ ★★☆☆☆ ★★☆☆☆
Performance ★☆☆☆☆ ★★☆☆☆ ★★★★★ ★★★★★ ★★★★★
Maintenance ★★★★☆ ★★★☆☆ ★★★★☆ ★★☆☆☆ ★★★★★
Overall ★★☆☆☆ ★★★☆☆ ★★★★☆ ★★★☆☆ ★★★★★

Of the five methods we covered, two are my favorites: using SVG (Method 3) and using Unicode characters in pseudo-elements (Method 5). There are definitely use cases where a background image makes a lot of sense, but that seems best evaluated case-by-case as opposed to a go-to solution.

You have to always consider all the benefits and downsides of a specific method. This is, in my opinion, is the beauty of front-end development! There are multiple ways to go, and proper experience is required to implement features efficiently.

The post Five Methods for Five-Star Ratings appeared first on CSS-Tricks.

Five Methods for Five-Star Ratings

Post pobrano z: Five Methods for Five-Star Ratings

In the world of likes and social statistics, reviews are very important method for leaving feedback. Users often like to know the opinions of others before deciding on items to purchase themselves, or even articles to read, movies to see, or restaurants to dine.

Developers often struggle with with reviews — it is common to see inaccessible and over-complicated implementations. Hey, CSS-Tricks has a snippet for one that’s now bordering on a decade.

Let’s walk through new, accessible and maintainable approaches for this classic design pattern. Our goal will be to define the requirements and then take a journey on the thought-process and considerations for how to implement them.

Scoping the work

Did you know that using stars as a rating dates all the way back to 1844 when they were first used to rate restaurants in Murray’s Handbooks for Travellers — and later popularized by Michelin Guides in 1931 as a three-star system? There’s a lot of history there, so no wonder it’s something we’re used to seeing!

There are a couple of good reasons why they’ve stood the test of time:

  1. Clear visuals (in the form of five hollow or filled stars in a row)
  2. A straightforward label (that provides an accessible description, like aria-label)

When we implement it on the web, it is important that we focus meeting both of those outcomes.

It is also important to implement features like this in the most versatile way possible. That means we should reach for HTML and CSS as much as possible and try to avoid JavaScript where we can. And that’s because:

  1. JavaScript solutions will always differ per framework. Patterns that are typical in vanilla JavaScript might be anti-patterns in frameworks (e.g. React prohibits direct document manipulation).
  2. Languages like JavaScript evolve fast, which is great for community, but not so great articles like this. We want a solution that’s maintainable and relevant for the long haul, so we should base our decisions on consistent, stable tooling.

Methods for creating the visuals

One of the many wonderful things about CSS is that there are often many ways to write the same thing. Well, the same thing goes for how we can tackle drawing stars. There are five options that I see:

  • Using an image file
  • Using a background image
  • Using SVG to draw the shape
  • Using CSS to draw the shape
  • Using Unicode symbols

Which one to choose? It depends. Let’s check them all out.

Method 1: Using an image file

Using images means creating elements — at least 5 of them to be exact. Even if we’re calling the same image file for each star in a five-star rating, that’s five total requests. What are the consequences of that?

  1. More DOM nodes make document structure more complex, which could cause a slower page paint. The elements themselves need to render as well, which means either the server response time (if SSR) or the main thread generation (if we’re working in a SPA) has to increase. That doesn’t even account for the rendering logic that has to be implemented.
  2. It does not handle fractional ratings, say 2.3 stars out of 5. That would require a second group of duplicated elements masked with clip-path on top of them. This increases the document’s complexity by a minimum of seven more DOM nodes, and potentially tens of additional CSS property declarations.
  3. Optimized performance ought to consider how images are loaded and implementing something like lazy-loading) for off-screen images becomes increasingly harder when repeated elements like this are added to the mix.
  4. It makes a request, which means that caching TTLs should be configured in order to achieve an instantaneous second image load. However, even if this is configured correctly, the first load will still suffer because TTFB awaits from the server. Prefetch, pre-connect techniques or the service-worker should be considered in order to optimize the first load of the image.
  5. It creates minimum of five non-meaningful elements for a screen reader. As we discussed earlier, the label is more important than the image itself. There is no reason to leave them in the DOM because they add no meaning to the rating — they are just a common visual.
  6. The images might be a part of manageable media, which means content managers will be able to change the star appearance at any time, even if it’s incorrect.
  7. It allows for a versatile appearance of the star, however the active state might only be similar to the initial state. It’s not possible to change the image src attribute without JavaScript and that’s something we’re trying to avoid.

Wondering how the HTML structure might look? Probably something like this:

<div class="Rating" aria-label="Rating of this item is 3 out of 5">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star Rating--Star__active">
  <img src="/static/assets/star.png" class="Rating--Star">
  <img src="/static/assets/star.png" class="Rating--Star">
</div>

In order to change the appearance of those stars, we can use multiple CSS properties. For example:

.Rating--Star {
  filter: grayscale(100%); // maybe we want stars to become grey if inactive
  opacity: .3; // maybe we want stars to become opaque
}

An additional benefit of this method is that the <img> element is set to inline-block by default, so it takes a little bit less styling to position them in a single line.

Accessibility: ★★☆☆☆
Management: ★★★★☆
Performance: ★☆☆☆☆
Maintenance: ★★★★☆
Overall: ★★☆☆☆

Method 2: Using a background image

This was once a fairly common implementation. That said, it still has its pros and cons.

For example:

  1. Sure, it’s only a single server request which alleviates a lot of caching needs. At the same time, we now have to wait for three additional events before displaying the stars: That would be (1) the CSS to download, (2) the CSSOM to parse, and (3) the image itself to download.
  2. It’s super easy to change the state of a star from empty to filled since all we’re really doing is changing the position of a background image. However, having to crack open an image editor and re-upload the file anytime a change is needed in the actual appearance of the stars is not the most ideal thing as far as maintenance goes.
  3. We can use CSS properties like background-repeat property and clip-path to reduce the number of DOM nodes. We could, in a sense, use a single element to make this work. On the other hand, it’s not great that we don’t technically have good accessible markup to identify the images to screen readers and have the stars be recognized as inputs. Well, not easily.

In my opinion, background images are probably best used complex star appearances where neither CSS not SVG suffice to get the exact styling down. Otherwise, using background images still presents a lot of compromises.

Accessibility: ★★★☆☆
Management: ★★★★☆
Performance: ★★☆☆☆
Maintenance: ★★★☆☆
Overall: ★★★☆☆

Method 3: Using SVG to draw the shape

SVG is great! It has a lot of the same custom drawing benefits as raster images but doesn’t require a server call if it’s inlined because, well, it’s simply code!

We could inline five stars into HTML, but we can do better than that, right? Chris has shown us a nice approach that allows us to provide the SVG markup for a single shape as a <symbol> and call it multiple times with with <use>.

<!-- Draw the star as a symbol and remove it from view -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="star" viewBox="214.7 0 182.6 792">
    <!-- <path>s and whatever other shapes in here -->  
  </symbol>
</svg>
    
<!-- Then use anywhere and as many times as we want! -->
<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

<svg class="icon">
  <use xlink:href="#star" />
</svg>

What are the benefits? Well, we’re talking zero requests, cleaner HTML, no worries about pixelation, and accessible attributes right out of the box. Plus, we’ve got the flexibility to use the stars anywhere and the scale to use them as many times as we want with no additional penalties on performance. Score!

The ultimate benefit is that this doesn’t require additional overhead, either. For example, we don’t need a build process to make this happen and there’s no reliance on additional image editing software to make further changes down the road (though, let’s be honest, it does help).

Accessibility: ★★★★★
Management: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★★★☆
Overall: ★★★★☆

Method 4: Using CSS to draw the shape

This method is very similar to background-image method, though improves on it by optimizing drawing the shape with CSS properties rather than making a call for an image. We might think of CSS as styling elements with borders, fonts and other stuff, but it’s capable of producing ome pretty complex artwork as well. Just look at Diana Smith’s now-famous “Francine” portrait.

Francine, a CSS replica of an oil painting done in CSS by Diana Smith (Source)

We’re not going to get that crazy, but you can see where we’re going with this. In fact, there’s already a nice demo of a CSS star shape right here on CSS-Tricks.

See the Pen
Five stars!
by Geoff Graham (@geoffgraham)
on CodePen.

Or, hey, we can get a little more crafty by using the clip-path property to draw a five-point polygon. Even less CSS! But, buyer beware, because your cross-browser support mileage may vary.

See the Pen
5 Clipped Stars!
by Geoff Graham (@geoffgraham)
on CodePen.

Accessibility: ★★★★★
Manangement: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★☆☆☆
Overall: ★★★☆☆

Method 5: Using Unicode symbols

This method is very nice, but very limited in terms of appearance. Why? Because the appearance of the star is set in stone as a Unicode character. But, hey, there are variations for a filled star (★) and an empty star (☆) which is exactly what we need!

Unicode characters are something you can either copy and paste directly into the HTML:

See the Pen
Unicode Stars!
by Geoff Graham (@geoffgraham)
on CodePen.

We can use font, color, width, height, and other properties to size and style things up a bit, but not a whole lot of flexibility here. But this is perhaps the most basic HTML approach of the bunch that it almost seems too obvious.

Instead, we can move the content into the CSS as a pseudo-element. That unleashes additional styling capabilities, including using custom properties to fill the stars fractionally:

See the Pen
Tiny but accessible 5 star rating
by Fred Genkin (@FredGenkin)
on CodePen.

Let’s break this last example down a bit more because it winds up taking the best benefits from other methods and splices them into a single solution with very little drawback while meeting all of our requirements.

Let’s start with HTML. there’s a single element that makes no calls to the server while maintaining accessibility:

<div class="stars" style="--rating: 2.3;" aria-label="Rating of this product is 2.3 out of 5."></div>

As you may see, the rating value is passed as an inlined custom CSS property (--rating). This means there is no additional rendering logic required, except for displaying the same rating value in the label for better accessibility.

Let’s take a look at that custom property. It’s actually a conversion from a value value to a percentage that’s handled in the CSS using the calc() function:

--percent: calc(var(--rating) / 5 * 100%);

I chose to go this route because CSS properties — like width and linear-gradient — do not accept <number> values. They accept <length> and <percentage> instead and have specific units in them, like % and px, em. Initially, the rating value is a float, which is a <number> type. Using this conversion helps ensure we can use the values in a number of ways.

Filling the stars may sound tough, but turns out to be quite simple. We need a linear-gradient background to create hard color stops where the gold-colored fill should end:

background: linear-gradient(90deg,
  var(--star-background) var(--percent), 
  var(--star-color) var(--percent)
);

Note that I am using custom variables for colors because I want the styles to be easily adjustable. Because custom properties are inherited from the parent elements styles, you can define them once on the :root element and then override in an element wrapper. Here’s what I put in the root:

:root {
  --star-size: 60px;
  --star-color: #fff;
  --star-background: #fc0;
}

The last thing I did was clip the background to the shape of the text so that the background gradient takes the shape of the stars. Think of the Unicode stars as stencils that we use to cut out the shape of stars from the background color. Or like a cookie cutters in the shape of stars that are mashed right into the dough:

-webkit-background-clip: text;
-webkit-text-fill-color: transparent;

The browser support for background clipping and text fills is pretty darn good. IE11 is the only holdout.

Accessibility: ★★★★★
Management: ★★☆☆☆
Performance: ★★★★★
Maintenance: ★★★★★
Overall: ★★★★★

Final thoughts

Image Files Background Image SVG CSS Shapes Unicode Symbols
Accessibility ★★☆☆☆ ★★★☆☆ ★★★★★ ★★★★★ ★★★★★
Management ★★★★☆ ★★★★☆ ★★☆☆☆ ★★☆☆☆ ★★☆☆☆
Performance ★☆☆☆☆ ★★☆☆☆ ★★★★★ ★★★★★ ★★★★★
Maintenance ★★★★☆ ★★★☆☆ ★★★★☆ ★★☆☆☆ ★★★★★
Overall ★★☆☆☆ ★★★☆☆ ★★★★☆ ★★★☆☆ ★★★★★

Of the five methods we covered, two are my favorites: using SVG (Method 3) and using Unicode characters in pseudo-elements (Method 5). There are definitely use cases where a background image makes a lot of sense, but that seems best evaluated case-by-case as opposed to a go-to solution.

You have to always consider all the benefits and downsides of a specific method. This is, in my opinion, is the beauty of front-end development! There are multiple ways to go, and proper experience is required to implement features efficiently.

The post Five Methods for Five-Star Ratings appeared first on CSS-Tricks.

PSA: Linking to a Code of Conduct Template is Not the Same as Having a Code of Conduct

Post pobrano z: PSA: Linking to a Code of Conduct Template is Not the Same as Having a Code of Conduct

Did you know we have a site that lists all upcoming conferences related to front-end web design and development? We do! If you’re looking to go to one, check it out. If you’re running one, feel free to submit yours.

Now that we’re running this, I’ve got loads of Pull Requests for conferences all around the world. I didn’t realize that many (most?) conferences use the template at confcodeofconduct.com. In fact, many of them just link to it and call it a day.

That’s why I’m very happy to see there is a new, bold warning about doing just that.

warning from https://confcodeofconduct.com/

Important notice

This code of conduct page is a template and should not be considered as enforceable. If an event has linked to this page, please ask them to publish their own code of conduct including details on how to report issues and where to find support.

It’s great that this site exists to give people some starter language for thinking about the idea of a code of conduct, but I can attest to the fact that many conferences used it as a way to appear to have a code of conduct before this warning while make zero effort to craft their own.

The primary concern about linking directly to someone else’s code of conduct or copy and pasting it to a new page verbatim is that there is nothing about what to do in case of problems. So, should a conduct incident occur, there is no documented information for what people should do in that event. Without actionable follow-through, a code of conduct is close to meaningless. It’s soul-less placating.

This is just one example:

It’s not to single someone out. It’s just one example of at least a dozen.

I heard from quite a few people about this, and I agree that it’s potentially a serious issue. I’ve tried to be clear about it: I won’t merge a Pull Request if the conference is missing a code of conduct or it simply links to confcodeofconduct.com (or uses a direct copy of it with no actionable details).

I know the repo is looking for help translating the new warning into different languages. If you can help with that, I’m sure they’d love a PR to the appropriate index HTML file.

The post PSA: Linking to a Code of Conduct Template is Not the Same as Having a Code of Conduct appeared first on CSS-Tricks.

3D Art Created to Illustrate Bad Behaviour on the London Underground

Post pobrano z: 3D Art Created to Illustrate Bad Behaviour on the London Underground

Bad behavior in public transportation is a worldwide issue, and the London Underground is no exception despite British citizens great reputation in terms of behavior in public spaces.

In this personal project, illustrator Matt Wood, who goes by the pseudonym Design Lad, created a set of colorful displays of commuters bad behaviors he could observe.

The 3D illustration style used is very in-your-face and makes the obnoxious behaviours even more blatant. The bright colors used add another layer of discomfort to the viewer, making the experience even more real.

Thanks for being a subscriber, here is your FREE house vector icons set.

3D Art Created to Illustrate Bad Behaviour on the London Underground

Post pobrano z: 3D Art Created to Illustrate Bad Behaviour on the London Underground

Bad behavior in public transportation is a worldwide issue, and the London Underground is no exception despite British citizens great reputation in terms of behavior in public spaces.

In this personal project, illustrator Matt Wood, who goes by the pseudonym Design Lad, created a set of colorful displays of commuters bad behaviors he could observe.

The 3D illustration style used is very in-your-face and makes the obnoxious behaviours even more blatant. The bright colors used add another layer of discomfort to the viewer, making the experience even more real.

Thanks for being a subscriber, here is your FREE house vector icons set.

3D Art Created to Illustrate Bad Behaviour on the London Underground

Post pobrano z: 3D Art Created to Illustrate Bad Behaviour on the London Underground

Bad behavior in public transportation is a worldwide issue, and the London Underground is no exception despite British citizens great reputation in terms of behavior in public spaces.

In this personal project, illustrator Matt Wood, who goes by the pseudonym Design Lad, created a set of colorful displays of commuters bad behaviors he could observe.

The 3D illustration style used is very in-your-face and makes the obnoxious behaviours even more blatant. The bright colors used add another layer of discomfort to the viewer, making the experience even more real.

Thanks for being a subscriber, here is your FREE house vector icons set.

How to Create a Cartoon Rainbow Text Effect in Photoshop

Post pobrano z: How to Create a Cartoon Rainbow Text Effect in Photoshop

Final product image
What You’ll Be Creating

Text effects and Photoshop text styles can be a lot of fun—they can be expressive, dynamic, and communicative! In this tutorial, we’ll create a rainbow text effect in Adobe Photoshop, using text effects, layer styles, and some other tricks, too!

Tutorial Assets

The following assets were used in this tutorial:

1. How to Arch Text in Photoshop

Step 1

First, begin with a New Document in Adobe Photoshop. You’re welcome to follow along with my settings, as shown below, but there is no wrong answer here! Choose a size that you prefer.

Example Settings

Step 2

Now, let’s begin with our text. Using the Type Tool, write out the word of your choice. 

I used the word „Rainbow” for this tutorial, but feel free to use any that you like. The techniques we’ll use in this walkthrough could apply to any typeface of your choice, as well.

I used the font Paladise

Example of Text

Step 3

To push the rainbow aesthetic further, we’re going to give the type an arch. 

Ever wondered how to curve text in Photoshop? With the Type Tool selected, choose Create Warped Text from the Options Bar. Doing so will bring up the dialog box displayed below.

We want to apply an Arc to our text. Select Horizontal and experiment with the values until you get a curvature that you like. Voila, you know how to arch text in Photoshop! In this case, I chose to set the Bend to 40%.

Example of Arc Added to Text

Step 4

After warping the text, the type might not fit your canvas the way it did prior. In my case, it stretched things out and made the text bigger than I’d originally wanted the text design. Use the Move Tool and your Transform Controls to adjust the type, if necessary.  

Example of Resized Text

2. How to Create the Rainbow Text Effect

Step 1

Now, let’s create the rainbow itself. There’s no right or wrong way to do this, but here is one way you could try.

Start by using the Ellipse Tool to create a rounded shape. Try to follow the curvature of the type. 

Ellipse added on top of Text

Step 2

Copy the ellipse and Move it upwards, changing its color each time. Once I was happy with my colors, I Flattened the ellipses onto one layer.

The red, however, needs to cover more space, to fully cover the top of the type. In this case, I created a New Layer beneath my ellipses and simply created a red rectangle. You could do this with your Shape Tools or simply Fill a selection made with your Selection Tools

Again, this is a case where this could be achieved in many ways. You could, for example, draw the rainbow by hand with a drawing tablet, or you could use the Pen Tool to achieve a similar effect. 

Choose the method you prefer—the important part is that the arc of the rainbow is inspired by the type and that the color completely covers the text area.

Example of initial Rainbow Artwork

Step 3

Once you’re happy with your rainbow, make sure it has all been Flattened onto one Layer. We’re going to Create a Clipping Mask on this Layer.

To do so, Right-Click on the layer (on PC) or Control-Click on the layer (on Mac) to open the Options seen below. Select Create Clipping Mask.

Creating the Clipping Mask

Step 4

Tah dah! Our rainbow has now been applied to the type area. Notice how, when the Clipping Mask is applied, the Layer has a little downwards arrow on it, indicating this.

If you’re unhappy with how your rainbow looks, you can draw directly on this Layer and the contents will still stay confined to the type area. Don’t be afraid to go in and make adjustments! 

Applying the Clipping Mask

3. How to Add Text Effects

Step 1

Now, let’s add some fun effects to push the aesthetic here further.

Rather than using the Drop Shadow Layer Effect, here in Photoshop, let’s create one by hand. 

First, I took our Text Layer and the Clipping Mask Layer and put them into a Folder. This will help keep things organized.

Copy the folder. I labeled these two folders „Rainbow Text Top” and „Rainbow Text Bottom”. The bottom folder is the start of our Drop Shadow. Use the Move Tool to move it downwards.

Creating a Drop Shadow by Hand

Step 2

Now, let’s create a New Layer, right above the rainbow colors applied to our text. Create a Clipping Mask on this Layer, just as we did earlier in this tutorial. 

Fill this Layer with a solid, black color (or, a different color of your choice, if you’d like!). Set the Opacity to 50%—this way, we still see the rainbow colors, but they look a little darker, like a rainbow-tinted shadow. 

Creating an Additional Clipping Mask

Step 3

Next, let’s give our text some depth. 

Copy the rainbow Text Layer and move this Copied Layer to the top of your list of Layers. Change the Color to white.

I have turned off visibility on my other rainbow text layers, so I can visually focus on this one (click the Eye Icons to the left of each Layer to Toggle Visibility On and Off

Duplicating the Text Layer and Making it White

Step 4

We’re going to apply two Layer Effects to the white Text Layer that we just copied. The first one is Bevel & Emboss.

Feel free to copy my settings, as shown below—but again, there is no wrong answer here. Experiment so you get a feel for what the values do! It is, however, important to note that the Highlight Mode is set to Screen and the Shadow Mode is set to Multiply.

Applying Bevel and Emboss

Step 5

Now, let’s also add an Inner Glow. Again, I recommend experimenting with these values to get a feel for what they do (Tip: Keep Preview checked so you can see what changes these values make, in real time). Note that the Blend Mode is set to Screen.

Once you’re happy with the values you’ve selected, click OK.

Applying an Inner Shadow

Step 6

Change the layer’s Blending Mode to Multiply. Notice how the white text disappears into the background, but we’re still left with visible Layer Effects

Changing the Layers Blending Mode

Step 7

Toggle the visibility on for any hidden layers, so we can see everything together now. 

Use the Move Tool to adjust the position of the layer with our Layer Effects, as necessary. I bumped it a little upwards and to the side to get the effect I wanted. 

Adjusting the Layers

4. How to Create Background Elements

Step 1

To push the rainbow aesthetic even further, I thought it would be cute to add in some raindrops. 

I used a drawing tablet to draw some white lines with the Brush Tool. The default Soft Round Brush will do! Then, in varied spots, I drew little spots and dashes to resemble splashes, where the raindrops hit the letters. 

If you don’t have a drawing tablet, that’s okay too! The artwork itself doesn’t have to be perfect—you could use your mouse or the Line Tool, for example, to get the basic shapes down.

Then, apply a Gaussian Blur (located under Filters > Gaussian Blur) to smooth things out and match the hazy white glow at the type of the type. Now, we have a rainy look!

Drawing on Rain Drops

Step 2

Let’s finish things off with a fun background. 

First, on a New Layer below all of the type, I created some simple clouds in a solid, white color. Again, I used my drawing tablet and the Brush Tool to do so—but you could use Shape Tools to achieve a similar result. 

I also added a Gradient, below. The goal was to make the base of the background a little darker than the top. You can do so with the Gradient Tool.

Adding in Clouds and a Gradient

Step 3

Finally, Copy the clouds and Move them so they create a repeated pattern. It doesn’t have to be perfect or symmetrical! Once you’re happy with where you’ve placed them, apply a Gaussian Blur and lower the Opacity of the layer to 80%.

Creating a Cloud Pattern in the Background

And There You Have It!

We’ve created a cartoon rainbow text effect in Adobe Photoshop! Photoshop text effects aren’t as tough as they look, right? I hope these techniques benefit your next project. 

Thank you for following along, and I hope you enjoyed this tutorial! 

Example of Finished Tutorial

If you enjoyed this tutorial, here are some others to check out!

How to Create a Cartoon Rainbow Text Effect in Photoshop

Post pobrano z: How to Create a Cartoon Rainbow Text Effect in Photoshop

Final product image
What You’ll Be Creating

Text effects and Photoshop text styles can be a lot of fun—they can be expressive, dynamic, and communicative! In this tutorial, we’ll create a rainbow text effect in Adobe Photoshop, using text effects, layer styles, and some other tricks, too!

Tutorial Assets

The following assets were used in this tutorial:

1. How to Arch Text in Photoshop

Step 1

First, begin with a New Document in Adobe Photoshop. You’re welcome to follow along with my settings, as shown below, but there is no wrong answer here! Choose a size that you prefer.

Example Settings

Step 2

Now, let’s begin with our text. Using the Type Tool, write out the word of your choice. 

I used the word „Rainbow” for this tutorial, but feel free to use any that you like. The techniques we’ll use in this walkthrough could apply to any typeface of your choice, as well.

I used the font Paladise

Example of Text

Step 3

To push the rainbow aesthetic further, we’re going to give the type an arch. 

Ever wondered how to curve text in Photoshop? With the Type Tool selected, choose Create Warped Text from the Options Bar. Doing so will bring up the dialog box displayed below.

We want to apply an Arc to our text. Select Horizontal and experiment with the values until you get a curvature that you like. Voila, you know how to arch text in Photoshop! In this case, I chose to set the Bend to 40%.

Example of Arc Added to Text

Step 4

After warping the text, the type might not fit your canvas the way it did prior. In my case, it stretched things out and made the text bigger than I’d originally wanted the text design. Use the Move Tool and your Transform Controls to adjust the type, if necessary.  

Example of Resized Text

2. How to Create the Rainbow Text Effect

Step 1

Now, let’s create the rainbow itself. There’s no right or wrong way to do this, but here is one way you could try.

Start by using the Ellipse Tool to create a rounded shape. Try to follow the curvature of the type. 

Ellipse added on top of Text

Step 2

Copy the ellipse and Move it upwards, changing its color each time. Once I was happy with my colors, I Flattened the ellipses onto one layer.

The red, however, needs to cover more space, to fully cover the top of the type. In this case, I created a New Layer beneath my ellipses and simply created a red rectangle. You could do this with your Shape Tools or simply Fill a selection made with your Selection Tools

Again, this is a case where this could be achieved in many ways. You could, for example, draw the rainbow by hand with a drawing tablet, or you could use the Pen Tool to achieve a similar effect. 

Choose the method you prefer—the important part is that the arc of the rainbow is inspired by the type and that the color completely covers the text area.

Example of initial Rainbow Artwork

Step 3

Once you’re happy with your rainbow, make sure it has all been Flattened onto one Layer. We’re going to Create a Clipping Mask on this Layer.

To do so, Right-Click on the layer (on PC) or Control-Click on the layer (on Mac) to open the Options seen below. Select Create Clipping Mask.

Creating the Clipping Mask

Step 4

Tah dah! Our rainbow has now been applied to the type area. Notice how, when the Clipping Mask is applied, the Layer has a little downwards arrow on it, indicating this.

If you’re unhappy with how your rainbow looks, you can draw directly on this Layer and the contents will still stay confined to the type area. Don’t be afraid to go in and make adjustments! 

Applying the Clipping Mask

3. How to Add Text Effects

Step 1

Now, let’s add some fun effects to push the aesthetic here further.

Rather than using the Drop Shadow Layer Effect, here in Photoshop, let’s create one by hand. 

First, I took our Text Layer and the Clipping Mask Layer and put them into a Folder. This will help keep things organized.

Copy the folder. I labeled these two folders „Rainbow Text Top” and „Rainbow Text Bottom”. The bottom folder is the start of our Drop Shadow. Use the Move Tool to move it downwards.

Creating a Drop Shadow by Hand

Step 2

Now, let’s create a New Layer, right above the rainbow colors applied to our text. Create a Clipping Mask on this Layer, just as we did earlier in this tutorial. 

Fill this Layer with a solid, black color (or, a different color of your choice, if you’d like!). Set the Opacity to 50%—this way, we still see the rainbow colors, but they look a little darker, like a rainbow-tinted shadow. 

Creating an Additional Clipping Mask

Step 3

Next, let’s give our text some depth. 

Copy the rainbow Text Layer and move this Copied Layer to the top of your list of Layers. Change the Color to white.

I have turned off visibility on my other rainbow text layers, so I can visually focus on this one (click the Eye Icons to the left of each Layer to Toggle Visibility On and Off

Duplicating the Text Layer and Making it White

Step 4

We’re going to apply two Layer Effects to the white Text Layer that we just copied. The first one is Bevel & Emboss.

Feel free to copy my settings, as shown below—but again, there is no wrong answer here. Experiment so you get a feel for what the values do! It is, however, important to note that the Highlight Mode is set to Screen and the Shadow Mode is set to Multiply.

Applying Bevel and Emboss

Step 5

Now, let’s also add an Inner Glow. Again, I recommend experimenting with these values to get a feel for what they do (Tip: Keep Preview checked so you can see what changes these values make, in real time). Note that the Blend Mode is set to Screen.

Once you’re happy with the values you’ve selected, click OK.

Applying an Inner Shadow

Step 6

Change the layer’s Blending Mode to Multiply. Notice how the white text disappears into the background, but we’re still left with visible Layer Effects

Changing the Layers Blending Mode

Step 7

Toggle the visibility on for any hidden layers, so we can see everything together now. 

Use the Move Tool to adjust the position of the layer with our Layer Effects, as necessary. I bumped it a little upwards and to the side to get the effect I wanted. 

Adjusting the Layers

4. How to Create Background Elements

Step 1

To push the rainbow aesthetic even further, I thought it would be cute to add in some raindrops. 

I used a drawing tablet to draw some white lines with the Brush Tool. The default Soft Round Brush will do! Then, in varied spots, I drew little spots and dashes to resemble splashes, where the raindrops hit the letters. 

If you don’t have a drawing tablet, that’s okay too! The artwork itself doesn’t have to be perfect—you could use your mouse or the Line Tool, for example, to get the basic shapes down.

Then, apply a Gaussian Blur (located under Filters > Gaussian Blur) to smooth things out and match the hazy white glow at the type of the type. Now, we have a rainy look!

Drawing on Rain Drops

Step 2

Let’s finish things off with a fun background. 

First, on a New Layer below all of the type, I created some simple clouds in a solid, white color. Again, I used my drawing tablet and the Brush Tool to do so—but you could use Shape Tools to achieve a similar result. 

I also added a Gradient, below. The goal was to make the base of the background a little darker than the top. You can do so with the Gradient Tool.

Adding in Clouds and a Gradient

Step 3

Finally, Copy the clouds and Move them so they create a repeated pattern. It doesn’t have to be perfect or symmetrical! Once you’re happy with where you’ve placed them, apply a Gaussian Blur and lower the Opacity of the layer to 80%.

Creating a Cloud Pattern in the Background

And There You Have It!

We’ve created a cartoon rainbow text effect in Adobe Photoshop! Photoshop text effects aren’t as tough as they look, right? I hope these techniques benefit your next project. 

Thank you for following along, and I hope you enjoyed this tutorial! 

Example of Finished Tutorial

If you enjoyed this tutorial, here are some others to check out!

How to Create a Cartoon Rainbow Text Effect in Photoshop

Post pobrano z: How to Create a Cartoon Rainbow Text Effect in Photoshop

Final product image
What You’ll Be Creating

Text effects and Photoshop text styles can be a lot of fun—they can be expressive, dynamic, and communicative! In this tutorial, we’ll create a rainbow text effect in Adobe Photoshop, using text effects, layer styles, and some other tricks, too!

Tutorial Assets

The following assets were used in this tutorial:

1. How to Arch Text in Photoshop

Step 1

First, begin with a New Document in Adobe Photoshop. You’re welcome to follow along with my settings, as shown below, but there is no wrong answer here! Choose a size that you prefer.

Example Settings

Step 2

Now, let’s begin with our text. Using the Type Tool, write out the word of your choice. 

I used the word „Rainbow” for this tutorial, but feel free to use any that you like. The techniques we’ll use in this walkthrough could apply to any typeface of your choice, as well.

I used the font Paladise

Example of Text

Step 3

To push the rainbow aesthetic further, we’re going to give the type an arch. 

Ever wondered how to curve text in Photoshop? With the Type Tool selected, choose Create Warped Text from the Options Bar. Doing so will bring up the dialog box displayed below.

We want to apply an Arc to our text. Select Horizontal and experiment with the values until you get a curvature that you like. Voila, you know how to arch text in Photoshop! In this case, I chose to set the Bend to 40%.

Example of Arc Added to Text

Step 4

After warping the text, the type might not fit your canvas the way it did prior. In my case, it stretched things out and made the text bigger than I’d originally wanted the text design. Use the Move Tool and your Transform Controls to adjust the type, if necessary.  

Example of Resized Text

2. How to Create the Rainbow Text Effect

Step 1

Now, let’s create the rainbow itself. There’s no right or wrong way to do this, but here is one way you could try.

Start by using the Ellipse Tool to create a rounded shape. Try to follow the curvature of the type. 

Ellipse added on top of Text

Step 2

Copy the ellipse and Move it upwards, changing its color each time. Once I was happy with my colors, I Flattened the ellipses onto one layer.

The red, however, needs to cover more space, to fully cover the top of the type. In this case, I created a New Layer beneath my ellipses and simply created a red rectangle. You could do this with your Shape Tools or simply Fill a selection made with your Selection Tools

Again, this is a case where this could be achieved in many ways. You could, for example, draw the rainbow by hand with a drawing tablet, or you could use the Pen Tool to achieve a similar effect. 

Choose the method you prefer—the important part is that the arc of the rainbow is inspired by the type and that the color completely covers the text area.

Example of initial Rainbow Artwork

Step 3

Once you’re happy with your rainbow, make sure it has all been Flattened onto one Layer. We’re going to Create a Clipping Mask on this Layer.

To do so, Right-Click on the layer (on PC) or Control-Click on the layer (on Mac) to open the Options seen below. Select Create Clipping Mask.

Creating the Clipping Mask

Step 4

Tah dah! Our rainbow has now been applied to the type area. Notice how, when the Clipping Mask is applied, the Layer has a little downwards arrow on it, indicating this.

If you’re unhappy with how your rainbow looks, you can draw directly on this Layer and the contents will still stay confined to the type area. Don’t be afraid to go in and make adjustments! 

Applying the Clipping Mask

3. How to Add Text Effects

Step 1

Now, let’s add some fun effects to push the aesthetic here further.

Rather than using the Drop Shadow Layer Effect, here in Photoshop, let’s create one by hand. 

First, I took our Text Layer and the Clipping Mask Layer and put them into a Folder. This will help keep things organized.

Copy the folder. I labeled these two folders „Rainbow Text Top” and „Rainbow Text Bottom”. The bottom folder is the start of our Drop Shadow. Use the Move Tool to move it downwards.

Creating a Drop Shadow by Hand

Step 2

Now, let’s create a New Layer, right above the rainbow colors applied to our text. Create a Clipping Mask on this Layer, just as we did earlier in this tutorial. 

Fill this Layer with a solid, black color (or, a different color of your choice, if you’d like!). Set the Opacity to 50%—this way, we still see the rainbow colors, but they look a little darker, like a rainbow-tinted shadow. 

Creating an Additional Clipping Mask

Step 3

Next, let’s give our text some depth. 

Copy the rainbow Text Layer and move this Copied Layer to the top of your list of Layers. Change the Color to white.

I have turned off visibility on my other rainbow text layers, so I can visually focus on this one (click the Eye Icons to the left of each Layer to Toggle Visibility On and Off

Duplicating the Text Layer and Making it White

Step 4

We’re going to apply two Layer Effects to the white Text Layer that we just copied. The first one is Bevel & Emboss.

Feel free to copy my settings, as shown below—but again, there is no wrong answer here. Experiment so you get a feel for what the values do! It is, however, important to note that the Highlight Mode is set to Screen and the Shadow Mode is set to Multiply.

Applying Bevel and Emboss

Step 5

Now, let’s also add an Inner Glow. Again, I recommend experimenting with these values to get a feel for what they do (Tip: Keep Preview checked so you can see what changes these values make, in real time). Note that the Blend Mode is set to Screen.

Once you’re happy with the values you’ve selected, click OK.

Applying an Inner Shadow

Step 6

Change the layer’s Blending Mode to Multiply. Notice how the white text disappears into the background, but we’re still left with visible Layer Effects

Changing the Layers Blending Mode

Step 7

Toggle the visibility on for any hidden layers, so we can see everything together now. 

Use the Move Tool to adjust the position of the layer with our Layer Effects, as necessary. I bumped it a little upwards and to the side to get the effect I wanted. 

Adjusting the Layers

4. How to Create Background Elements

Step 1

To push the rainbow aesthetic even further, I thought it would be cute to add in some raindrops. 

I used a drawing tablet to draw some white lines with the Brush Tool. The default Soft Round Brush will do! Then, in varied spots, I drew little spots and dashes to resemble splashes, where the raindrops hit the letters. 

If you don’t have a drawing tablet, that’s okay too! The artwork itself doesn’t have to be perfect—you could use your mouse or the Line Tool, for example, to get the basic shapes down.

Then, apply a Gaussian Blur (located under Filters > Gaussian Blur) to smooth things out and match the hazy white glow at the type of the type. Now, we have a rainy look!

Drawing on Rain Drops

Step 2

Let’s finish things off with a fun background. 

First, on a New Layer below all of the type, I created some simple clouds in a solid, white color. Again, I used my drawing tablet and the Brush Tool to do so—but you could use Shape Tools to achieve a similar result. 

I also added a Gradient, below. The goal was to make the base of the background a little darker than the top. You can do so with the Gradient Tool.

Adding in Clouds and a Gradient

Step 3

Finally, Copy the clouds and Move them so they create a repeated pattern. It doesn’t have to be perfect or symmetrical! Once you’re happy with where you’ve placed them, apply a Gaussian Blur and lower the Opacity of the layer to 80%.

Creating a Cloud Pattern in the Background

And There You Have It!

We’ve created a cartoon rainbow text effect in Adobe Photoshop! Photoshop text effects aren’t as tough as they look, right? I hope these techniques benefit your next project. 

Thank you for following along, and I hope you enjoyed this tutorial! 

Example of Finished Tutorial

If you enjoyed this tutorial, here are some others to check out!