I have a sidebar made with Tailwind CSS and I'd like to make it scrollable. My problem is, that when you hover over an entry in the list, a small text label should be displayed next to the entry, outside of the sidebar (shown below).
When I use overflow-y-scroll
it scrolls fine on the Y-axis, but instead of displaying the hover text next to the sidebar, it makes the sidebar scrollable on the X-axis and basically hides the text.
My Sidebar JSX:
<aside className="fixed top-0 left-0 h-screen w-16 m-0 flex flex-col bg-red-800 text-white shadow-lg">
<div className='overflow-y-scroll'>
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
<SidebarIcon text="asdf" icon={0} />
<SidebarIcon text="asdf" icon={1} />
<SidebarIcon text="asdf" icon={2} />
</div>
</aside>
My SidebarIcon component:
const SidebarIcon = function ({ icon, text}) {
let icons = [
<FontAwesomeIcon icon={solid('display')} className="w-[28px] h-[28px]" size='28'/>, // Desktop 0
<FontAwesomeIcon icon={solid('laptop')} className="w-[28px] h-[28px]" size='28'/>, // Laptop 1
<FontAwesomeIcon icon={solid('mobile-screen')} className="w-[28px] h-[28px]" size='28'/> // Mobile 2
]
return (
<div className={`sidebar-icon group shrink-0`}>
{ icons[icon] }
<span class='sidebar-tooltip group-hover:scale-100'> { text } </span>
</div>
)
}
And at last the CSS for the icons:
.sidebar-icon {
@apply bg-red-900 text-gray-50;
@apply relative flex items-center justify-center;
@apply h-12 w-12 mx-auto my-2;
@apply shadow-lg rounded-lg;
@apply transition-all duration-150 ease-linear;
@apply hover:bg-gray-800 hover:text-red-800;
}
.sidebar-tooltip{
@apply absolute w-auto p-2 m-2 min-w-max left-14;
@apply rounded-md shadow-md;
@apply text-white bg-gray-900;
@apply text-xs font-bold;
@apply transition-all duration-100 scale-0 origin-left
}