Skip to content

Instantly share code, notes, and snippets.

@shvchk
Last active January 20, 2024 18:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shvchk/ea637112f88fe29a3f21c141a9fcf709 to your computer and use it in GitHub Desktop.
Save shvchk/ea637112f88fe29a3f21c141a9fcf709 to your computer and use it in GitHub Desktop.
userChrome.css: Floating collapsible sidebar for vertical tabs. Video demo: https://youtu.be/bonasv2q98U
@-moz-document url("chrome://browser/content/browser.xhtml") {
/* To bring back OS title bar with min/max/close buttons, some users might
* consider setting browser.tabs.drawInTitlebar to false in about:config
*/
:root {
--custom-sidebar-collapsed-width: 35px;
--custom-sidebar-full-width: 20vw;
--custom-sidebar-border: 0px solid #404040;
}
#TabsToolbar {
visibility: collapse !important;
}
#navigator-toolbox {
border-bottom: 0 !important;
}
#browser {
position: relative;
}
#sidebar-box:not([hidden]) {
position: absolute;
z-index: 1;
display: flex;
flex-direction: column;
overflow: hidden;
border-right: var(--custom-sidebar-border);
min-width: var(--custom-sidebar-collapsed-width) !important;
width: var(--custom-sidebar-collapsed-width) !important;
height: 100%;
transition: all 0.2s ease;
}
#sidebar-box:hover,
#sidebar-header,
#sidebar {
width: var(--custom-sidebar-full-width) !important;
}
#sidebar {
flex-grow: 1;
}
#sidebar-splitter {
display: none;
}
#sidebar-box:not([hidden]) ~ #appcontent {
margin-left: var(--custom-sidebar-collapsed-width);
}
#sidebar-box:not([hidden]) ~ #appcontent .findbar-container {
min-width: calc(100vw - 48px - var(--custom-sidebar-collapsed-width)) !important;
}
/* Sidebar on the right */
#sidebar-box[positionend="true"]:not([hidden]) {
right: 0;
}
#sidebar-box[positionend="true"]:not([hidden]) ~ #appcontent {
margin-left: 0;
margin-right: var(--custom-sidebar-collapsed-width);
border-right: 0;
border-left: var(--custom-sidebar-border);
}
/* Full screen */
#main-window[inFullscreen][inDOMFullscreen] #appcontent {
margin-left: 0;
margin-right: 0;
}
/* Place sidebar header at the bottom */
/*
#sidebar-box:not([hidden]) {
flex-direction: column-reverse;
}
*/
/* Collapsible sidebar header
* works best when positioned at the bottom
*/
/*
#sidebar-header {
border: 0 !important;
padding: 0 !important;
height: 1px;
opacity: 0;
}
#sidebar-header:hover {
padding: 8px !important;
height: auto;
opacity: 1;
}
*/
/* Hide sidebar header */
/*
#sidebar-header {
display: none;
}
*/
}
@andersjohansson
Copy link

That’s great, I love flexbox 😄! Another change that I think is needed so that it’s really hidden when switching on/off the sidebar (why anyone would like that with this brilliant unobtrusive ~30-40px favicon border is beyond me though) is to use #sidebar-box:not([hidden]) as selector. See discussion here: https://framagit.org/ariasuni/tabcenter-reborn/issues/54#note_518975

@shvchk
Copy link
Author

shvchk commented Dec 10, 2019

Nice catch, fixed, thanks!

@handy1957
Copy link

Ok, I'm a total newbie and I'm just now learning the css thing. Before I applied this css my tabs were on the right.
Is there any way to get them back to the right side?

@shvchk
Copy link
Author

shvchk commented Sep 12, 2021

@handy1957 Sidebar header has a menu with an option to move sidebar to the right.

@handy1957
Copy link

Awesome, Thank you.

@shvchk
Copy link
Author

shvchk commented Sep 14, 2021

New version with no need to manually calculate top panel heights. This CSS now works out of the box, no configuration required.

@shvchk
Copy link
Author

shvchk commented Nov 18, 2022

@Froggy232 and @GrigorijST , see this gist for FF 107 sidebar auto-shrinking fix

@Froggy232
Copy link

Thanks you A LOT!
It works flawlessly without configurations, that's the best userChrome.css that I have tried, thanks you again

@NinjaTuna007
Copy link

I'm trying to use this userChrome.css script, and it's really great! I'm unable to move tabs around and rearrange them inside the same panel, because as soon as I click and start dragging a tab, the sidebar collapses completely. I can move tabs from one panel to another, but not within the same panel. What would you recommend?

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