Skip to content

Instantly share code, notes, and snippets.

@focus97
Last active April 13, 2023 17:07
Show Gist options
  • Star 41 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save focus97/21a8b7f130f0afd0b26f0d84f3a02d2b to your computer and use it in GitHub Desktop.
Save focus97/21a8b7f130f0afd0b26f0d84f3a02d2b to your computer and use it in GitHub Desktop.
How to theme Slack (Dark, Solarized, White, Rosé, whatever)

How to theme Slack v4.12.0+

Update as of 8.08.2021:

  • Hid the bookmarks bar and fine-tuned some header styles.

If you want to add your own style to Slack, here's how.

My quazi-Tron Theme'ish?

I dunno what happened. I just wanted to try something sporty/future-y, I guess. Code for this is directly below.

image

Works on OSX, Linux, and should work on Windows too (I think)

Just requires some CSS injection via Javascript.

Slack v4.0 and above

In order to get Slack v4 and up to work, you'll need a simple Node package. If you are comfortable with opening a Javascript file and modifying it, running a couple extra Terminal commands will be no big deal. Note: you will need Admin access to your computer for this to work (as far as I can tell).

Here's how I'm able to do it on macOS Mojave:

1.) Install Node package first. Open up a Terminal and run:

npm install -g asar

This will install a package that will allow you to unpack Slack's app.asar archive, which is where the JS file we need to modify lives.

2.) Within the Terminal, navigate to the directory where the app.asar file lives:

cd /Applications/Slack.app/Contents/Resources/

(again, this is the location on my Mac)

3.) Extract the Asar archive (you may need to run as super user, so I'll just include that code here):

sudo asar extract app.asar app; sudo asar extract app-arm64.asar app-arm64; sudo asar extract app-x64.asar app-x64;

This extracts the asar's contents to newly creatd directories within the current directory.

4.) From this great article (https://www.codepicky.com/hacking-electron-restyle-skype/), Slack will either look for an asar archive OR the /{extracted asar app from above} directory. Let's tell Slack to ignore the archive:

sudo mv app.asar app.asar.bak; 

5.) Now we need to modify three files. First, run this command:

open app/index.js

On lines 2 and 4, remove the .asar from the resolve() function. Your finished file should look like

if (process.arch === 'arm64') {
  process._archPath = require.resolve('../app-arm64');
} else {
  process._archPath = require.resolve('../app-x64');
}

require(process._archPath);

Now open one of these two files (depending on your architecture) in order to place our custom code:

open /Applications/Slack.app/Contents/Resources/app-x64/dist/preload.bundle.js;
open /Applications/Slack.app/Contents/Resources/app-arm64/dist/preload.bundle.js

Lastly, at the bottom of both of those files, place this code below and save the file.

document.addEventListener('DOMContentLoaded', function() {
     
  
var tt__customCss = `
        #team_menu, .p-channel_sidebar, .p-team_sidebar--frameless::before, body, .channel_header, #footer, .channel_title_info, #channel_topic_text, .p-message_pane .c-message_list.c-virtual_list--scrollbar > .c-scrollbar__hider, .p-classic_nav, footer, .p-classic_nav__team_header, .p-prefs_modal, .c-fullscreen_modal__header, .workspace__primary_view_footer, .p-workspace__primary_view_footer, .p-message_input__input_container_unstyled, .p-composer_page, .p-composer_page__subheader { background: #010a18 !important; }
        .p-channel_sidebar__channel--selected, .p-channel_sidebar__link--selected, .c-message_list__day_divider__label__pill, .c-button--primary, .p-team_sidebar__mentions_badge { color: #000 !important; background: #f4b301 !important; }
        .c-message_kit__background, .c-wysiwyg_container__formatting { background: transparent; }
        .p-workspace__primary_view { border-left: 1px solid #f4b301; }
        .p-client_desktop--ia-top-nav .p-team_sidebar { border-right: 1px solid #f4b301; }
        .p-top_nav { background: #f4b301 !important; }
        .p-channel_sidebar__presence_icon.c-presence--active, .p-top_nav--iap2 .p-ia__nav__user__presence { color: #f4b301 !important; }
        .c-wysiwyg_container--theme_dark_bordered:focus-within, .c-message_list__day_divider__line, .p-ia__sidebar_header--top-nav .p-ia__sidebar_header__button, .p-ia__sidebar_header--top-nav .p-ia__sidebar_header__mode { border-color: #f4b301 !important; }
        .p-top_nav__sidebar button, .p-top_nav__windows_controls_container button, .p-channel_sidebar__channel--selected .p-channel_sidebar__channel_icon_prefix { color: black !important; }
        pre, .p-channel_sidebar--iap1 .p-channel_sidebar__section_heading, .p-drag_layer .p-channel_sidebar__section_heading, .p-ia__sidebar_header, .p-ia__view_header, .c-texty_input__container--sticky_composer .c-texty_input.focus~.p-texty_sticky_formatting_bar, .p-team_sidebar, .p-view_header, .p-huddle_sidebar_footer__join_non_active_container { background: black !important; }
        .p-message_pane .c-message_list.c-virtual_list--scrollbar>.c-scrollbar__hider:before, .p-bookmarks_bar_container { display: none;}
        .p-file_drag_drop__container { z-index: 1}
        .p-view_header { height: 50px; }
        .c-virtual_list__item--sticky { top: 0 !important;}
        .p-ia__view_header, .p-view_header, .p-composer_page__subheader, .p-channel_sidebar__pages_list_spacer { position: relative; z-index: 2; border-bottom: 1px solid #f4b301 !important; }
        .p-huddle_sidebar_footer__join_non_active_container { border-top: 1px solid #f4b301;}
    `;
    var head = document.head;
    var darkStyles  = document.createElement('style');
    darkStyles.appendChild(document.createTextNode(tt__customCss));
    head.appendChild(darkStyles);
});

6.) Last step: choose Slack's "Dark" theme (in Preferences -> Themes) as a baseline set of colors/styles that the above code will expand upon.

Style your own

If you have some CSS and browser devtools experience, you can customize the colors all you want. Slack has a way to expose their devtools.

On OSX, first quit Slack, then run this command in the Terminal: export SLACK_DEVELOPER_MENU=true; open -a /Applications/Slack.app

Once you do that, Slack will open up and you can hit the View menu to find a new Developer entry. I used Toggle WebApp DevTools to check the dom for the selectors I wanted to style.

@briantully
Copy link

@focus97 you are a legend! Thanks so much for realizing that jQuery wasn't being used anymore and that the styles needed to be inline. Looks like I have some work to do porting my v3 dark theme over to v4, but this is a great start. Thanks again!

@focus97
Copy link
Author

focus97 commented Jul 24, 2019

@briantully - glad it's working for you. Fun to figure this stuff out and make Slack easier on the eyes.

@mikey-t
Copy link

mikey-t commented Aug 1, 2019

@focus97 I wish I had seen your post earlier. I ended up creating a shell script to help me unpack/pack my injected js/css from my old hacked theme: https://github.com/mikey-t/slack-dark-theme. The CSS needs a little work, but the injection method makes it really fast for rapid trial and error changes. If someone wanted to use the injection method they could just add their own css file to the folder and point the shell script to it.

@focus97
Copy link
Author

focus97 commented Aug 2, 2019

@mikey-t hopefully the method i'm posting works well on your side. Just saw Slack's 4.0.1 update and it of course broke my custom theme. Ran through the steps and now it's back in order. Just added some additional styles to my theme above, as I caught some styles that needed work.

@mikey-t
Copy link

mikey-t commented Aug 2, 2019

I've now got my shell script to a point where it's re-runnable (it removes the previous injected content before re-injecting). If you want, you could actually download my repo and just replace my css with yours if you want a fast way to re-inject your css and/or make css fixes and quickly test them. I was making changes this morning and it was super quick. Got a terminal window open with sudo access and I can just make a change, re-run script, reload slack. Was able to make a few dozen css changes in just a few minutes.

@AlexPoirier1
Copy link

Slack 4.0.1 on MacOS broke the side-thread input text color for me. It's now white on white when typing

Great job on this by the way! I'm really glad I found this :)

@focus97
Copy link
Author

focus97 commented Aug 15, 2019

Thanks @AlexPoirier1. Glad it's working for you. FYI: I think i saw what you meant about the side-thread input. The text color is white but so is the background. Just fixed that with the latest update above. :)

@gkostov
Copy link

gkostov commented Nov 7, 2019

Ok, so Slack finally got a native dark theme (at least on a Mac here). This whole non-sense about chasing every app update will finally stop :)

Cheers everyone.

@focus97
Copy link
Author

focus97 commented Nov 18, 2019

Well, Slack having a "dark" theme wasn't the only impetus for creating a custom theme... :)

@rawkout1337
Copy link

rawkout1337 commented Mar 23, 2020

I am pretty new to CSS, but I was able to change everything with the exception of the defult "bluish gray" background colour of messages other people send me. Is there a line for changing this? or is it controlled somewhere else?

running v 4.4.0, 64-bit Windows 10
Message Colour

@krisrice
Copy link

Just used this to change the font to https://github.com/source-foundry/Hack

[lang] body{font-family: Hack,Slack-Lato,appleLogo,sans-serif;}
[lang] .c-texty_input{font-family: Hack,Slack-Lato,appleLogo,sans-serif;}

image

@focus97
Copy link
Author

focus97 commented Jul 21, 2020

Nice work @krisrice. Hack is my goto font for VS Code. Definitely a favorite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment