Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Custom Scrollbar</title> <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.2.1"></script> </head> <body class="antialiased"> <div class="bg-slate-50 dark:bg-slate-900 min-h-screen p-8 flex items-center justify-center"> <div class="max-w-md w-full bg-white dark:bg-slate-800 rounded-xl shadow-lg border border-slate-200 dark:border-slate-700 overflow-hidden"> <div class="p-4 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800"> <h2 class="font-bold text-slate-800 dark:text-white">Custom Scrollbar Utility</h2> <p class="text-xs text-slate-500 mt-1">Using scrollbar utilities in CSS or Tailwind variations</p> </div> <div class="h-64 p-6 overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-slate-100 [&::-webkit-scrollbar-track]:rounded-full [&::-webkit-scrollbar-thumb]:bg-slate-300 [&::-webkit-scrollbar-thumb]:rounded-full dark:[&::-webkit-scrollbar-track]:bg-slate-700 dark:[&::-webkit-scrollbar-thumb]:bg-slate-500 hover:[&::-webkit-scrollbar-thumb]:bg-slate-400 dark:hover:[&::-webkit-scrollbar-thumb]:bg-slate-400"> <h3 class="font-semibold text-lg mb-4 text-slate-800 dark:text-white">Scroll Down</h3> <p class="text-slate-600 dark:text-slate-400 mb-4">Tailwind CSS 4 lets you style scrollbars easily using arbitrary variants or arbitrary properties.</p> <p class="text-slate-600 dark:text-slate-400 mb-4">You can style the scrollbar width, track background, and thumb background completely seamlessly.</p> <div class="h-32 bg-indigo-50 dark:bg-indigo-900/30 rounded-lg border border-indigo-100 dark:border-indigo-800/50 my-4 flex items-center justify-center"> <span class="text-indigo-400 font-medium">Keep scrolling...</span> </div> <p class="text-slate-600 dark:text-slate-400 mb-4">Notice how the scrollbar thumb is rounded and matches the theme colors based on dark or light mode.</p> <div class="h-32 bg-rose-50 dark:bg-rose-900/30 rounded-lg border border-rose-100 dark:border-rose-800/50 my-4 flex items-center justify-center"> <span class="text-rose-400 font-medium">Almost there...</span> </div> <p class="text-slate-600 dark:text-slate-400">You have reached the bottom of the container.</p> </div> </div> </div> </body> </html>