DEV Community

Cover image for CSS Logos: Slack logo
Chris Bongers
Chris Bongers

Posted on • Edited on • Originally published at daily-dev-tips.com

CSS Logos: Slack logo

In this article, I wanted to look at the slack logo, I had this logo in my head for the past couple of days, and this is quite an interesting one as it's one of the views that work well for a grid-based layout.

This is the logo I'm talking about:

Slack Logo

Analysing the logo

As you might have seen, this logo can easily be broken up into squares, where some of the elements span over two of them.

Here is a screenshot of the finished product with the grid active.

Slack logo in a grid

We can set up a grid and use some generic styles to re-use some of the elements' layouts.

Let's get right into it and see how this works.

Creating the Slack logo in CSS Grid

.slack {
  width: 16rem;
  aspect-ratio: 1;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
Enter fullscreen mode Exit fullscreen mode

This will create the primary grid that we can start filling up with our pieces.

Empty grid

Let's get started on the top left blue item section first.

In our HTML, we can add the following elements.

<div class="slack">
  <div class="blue small"></div>
  <div class="blue big"></div>
</div>
Enter fullscreen mode Exit fullscreen mode

Since every pill is rounded technically, we can add that as one styling element for all divs.

.slack {
  & > div {
    border-radius: 9999px;
  }
}
Enter fullscreen mode Exit fullscreen mode

Note: The above and some code below will be SCSS code

Then we can start positioning our elements on the grid. The simplest one here is the bottom one, as that should span over two columns and sit on the second row.

.blue {
  background: #36c5f0;
  &.big {
    grid-row: 2;
    grid-column: span 2;
  }
}
Enter fullscreen mode Exit fullscreen mode

As you can see, we set this element to be on row two and span over two columns.

We can do something similar for the small one, but not round the bottom right corner.

.blue {
  &.small {
    grid-column-start: 2;
    border-bottom-right-radius: 0px;
  }
}
Enter fullscreen mode Exit fullscreen mode

So far, we should have the following look:

Slack top left item

But, we can quickly see it's too smooshed together, so let's add a gap to our grid.

.slack {
  gap: 0.5rem;
}
Enter fullscreen mode Exit fullscreen mode

Now we can add the other three sides and position them accordingly. The main thing that changes is the column/row start and end and which border we turn off.

<div class="slack">
  <div class="blue small"></div>
  <div class="blue big"></div>
  <div class="green small"></div>
  <div class="green big"></div>
  <div class="red small"></div>
  <div class="red big"></div>
  <div class="yellow small"></div>
  <div class="yellow big"></div>
</div>
Enter fullscreen mode Exit fullscreen mode

And for the CSS dump, please check this CodePen to see what's happening.

Do note there are multiple correct ways of determining the column/row start and end.

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Top comments (4)

Collapse
 
svgatorapp profile image
SVGator

Quick and easy 🙌

Collapse
 
renanfranca profile image
Renan Franca

So far this is the best "breakdown of the complexity into simple parts process" from that series 👏

Collapse
 
dailydevtips1 profile image
Chris Bongers

Thanks! Improving as we go 🤘

Collapse
 
theabhayprajapati profile image
Abhay Prajapati

so osm😇