Base Components

Tailwind CSS Scrollable

Tailwind CSS Scrollable makes it easy to add vertically or horizontally scrollable sections with custom scrollbar styles, perfect for long lists, data tables, or extended content.

Default Scrollable

To implement a custom scrollable content with a fixed height, simply utilize the scrollable custom class. This class is designed to create a improved scrollable area within your HTML document.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code.

Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

Hover

Use the scrollable-hover custom class to implement a scrollable content area with a customized scrollbar, which becomes visible upon mouse hover.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code.

Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

Horizontal

Below example demonstrates horizontally scrollable content.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS. With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code. Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

Both Scrollbars

Below example demonstrates a scrollable content with bith horizontal and vertical scrollbars.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS. With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code. Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code. Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code. Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

Auto Height

Use data-scrollable="true" to auto initialize the Tailwind CSS KTScrollable component that dynamically calculates the height of the scrollable content by subtracting the the total heights of specific elements defined via data-scrollable-dependencies="#header, #footer" the total spacings of specific elements defined via data-scrollable-wrappers="#header, #footer" within the HTML document.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code.

Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

With Modal

Apply the scrollable-y class to the modal-body element to enable vertical scrolling within the scrollable body.

With Card

Apply the scrollable-y class to the card-body element to enable vertical scrolling within the scrollable card.

Card Title

Tailwind CSS, a utility-first CSS framework, has gained immense popularity for its simplicity, flexibility, and efficiency in building modern web interfaces. Among its plethora of features, one that stands out is its ability to swiftly create stylish and responsive card components. These card components serve as fundamental building blocks for organizing content, displaying information, and enhancing user experience across web applications and websites
The Tailwind CSS card component offers developers a seamless way to structure content within a visually appealing container. With Tailwind's utility classes, creating cards becomes intuitive and hassle-free, allowing developers to focus on crafting engaging user interfaces rather than wrestling with complex CSS code

Customization

Customize the scrollbar thumb color to match your design requirements using the CSS variable --tw-scrollbar-thumb-color: var(--tw-success) .

Tailwind CSS is a popular utility-first CSS framework that streamlines web development by providing a comprehensive set of pre-designed classes. It offers developers the flexibility to rapidly build responsive and visually appealing user interfaces without the need for writing custom CSS.

With Tailwind CSS, you can easily create layouts, style typography, add colors, apply spacing, and more, using intuitive class names that directly map to CSS properties. Whether you're working on a small project or a large-scale application, Tailwind CSS empowers you to efficiently design and customize your web pages.

One of the standout features of Tailwind CSS is its modular approach, which encourages code reuse and maintains consistency across your project. By composing classes together, you can quickly prototype and iterate on design concepts, resulting in cleaner and more maintainable code.

Moreover, Tailwind CSS provides excellent support for responsive design, allowing you to create fluid layouts that adapt seamlessly to different screen sizes and devices. With built-in breakpoints and utility classes like sm:, md:, lg:, and xl:, you can easily customize the appearance of your website for various viewports.

Source Code

The following source files manage the JavaScript behavior and CSS styles of the Tailwind CSS Scrollable component. Upon building the assets using Webpack Build Tools , these files are compiled and added into the dist/assets/css/styles.css and dist/assets/js/core.bundle.js bundles, making them available globally across all pages.
File Description
src/core/components/scrollable/scrollable.ts The TypeScript source file that manages the JavaScript behavior of the Tailwind CSS Scrollable component.
src/core/plugins/components/scrollable.js The Tailwind CSS compatible plugin written in PostCSS for applying CSS styles to the Tailwind CSS Scrollable component.

HTML Markup

The following markup outlines the core structure of the Tailwind CSS Scrollable component.
				
					<div class="scrollable h-[300px]">
 Content goes here...
</div>

				
			

Classes

This table outlines the custom CSS classes utilized for styling the default components of the Tailwind CSS Scrollable.
Class Description
scrollable Adds both horizontal and vertical scrolling to the content.
scrollable-x Adds horizontal scrolling to the content.
scrollable-y Adds vertical scrolling to the content.
scrollable-auto Automatically adds scrolling based on content overflow.
scrollable-x-auto Automatically adds horizontal scrolling based on content overflow.
scrollable-y-auto Automatically adds vertical scrolling based on content overflow.
scrollable-hover Adds scrollbars on hover.
scrollable-x-hover Adds horizontal scrollbars on hover.
scrollable-y-hover Adds vertical scrollbars on hover.

Data Attribute Initialization

Auto-initialize all KTScrollable instances on page load by adding the data-scrollable="true" attribute to your scrollable elements. This triggers on the fly initialization by the KTScrollable JavaScript component and auto calculated the scrollable element height.
				
					<div class="scrollable-y" data-scrollable="true" data-scrollable-dependencies="#header, #footer" data-scrollable-height="auto" data-scrollable-offset="10px" data-scrollable-wrappers="#page, #wrapper, #content">
 Content goes here...
</div>

				
			
These attributes allow you to set options for the KTScrollable component during initialization. The values you provide as strings are automatically converted to the appropriate KTScrollable Options .
HTML Attribute Type Default Description
data-scrollable boolean true Automatically initializes KTScrollable instances on page load. Alternatively, you can remove it and perform initialization using JavaScript.
data-scrollable-save boolean true Enables saving the last scroll position in browser storage.
data-scrollable-dependencies string - Specifies the comma-separated IDs of elements whose heights are calculated and subtracted from the window offset height to determine scrollable height.
data-scrollable-wrappers string - Specifies the comma-separated IDs of elements whose spacings(margin, padding, border widths) are calculated and subtracted from the window offset height to determine scrollable height.
data-scrollable-offset string "0px" Specifies the offset CSS value in pixel to subtract from the calculated height.

JavaScript Initialization

To initialize a new scrollable component, pass the corresponding DOM element and configuration options to the KTScrollable class constructor.
				
					// Scrollable element
const scrollableEl = document.querySelector('#my_scrollable');

// Configuration options(optional)
const options = {
	save: true,
	dependencies: '#header, #footer',
	wrappers: '#page, #wrapper, #content',
	offset: 10
};

// Initialize object
const scrollable = new KTScrollable(scrollableEl, options);

				
			

To initialize the scrollable with JavaScript, use data-scrollable="false" attribute instead. This prevents automatic initialization on page load.

Options

This table outlines the configuration options for initialization of Tailwind CSS Scrollable instances, using the KTScrollable JavaScript component.
Option Type Default Description
save boolean true Enables saving the last scroll position in browser storage.
dependencies string - Specifies the comma-separated IDs of elements whose heights are calculated and subtracted from the window offset height to determine scrollable height.
wrappers string - Specifies the comma-separated IDs of elements whose spacings(margin, padding, border widths) are calculated and subtracted from the window offset height to determine scrollable height.
offset string "0px" Specifies the offset CSS value in pixel to subtract from the calculated height.

Utilities

Manage and interact with KTScrollable instances using these static methods of KTScrollable class.
Method Description
init() Automatically initializes KTScrollable object for all elements with the data-scrollable="true" attribute on page load.
createInstances() Allows to create KTScrollable instances for all elements that have been dynamically added to the DOM but haven't been activated yet.
getInstance(element) Returns the KTScrollable object associated with the given DOM element element .
getOrCreateInstance(element) Returns the existing KTScrollable object for the provided DOM element element , or creates a new instance if none exists, then returns the same.
				
					// Initialize all scrollables
KTScrollable.init()

// Initialzie pending scrollables
KTScrollable.createInstances();

// Get scrollable object
const scrollableEl = document.querySelector('#my_scrollable');
const scrollable = KTScrollable.getInstance(scrollableEl);

				
			

Methods

Use KTScrollable component's API methods to programmatically control its behavior.
Method Description
new KTScrollable(element, options) Creates an object instance of KTScrollable class for the given DOM element and configuration options .
update() Updates the calculated height.
getHeight() Returnes calculated height.
getOption(name) Retrieves the value of a configuration option by name parameter from a KTScrollable instance.
getElement() Retrieves the DOM element linked to a specific KTScrollable instance.
on(eventName, handler) Allows attaching event listeners to the KTScrollable custom events using the eventName and eventId string parameters. These events enable programmatic interaction based on user actions or internal state changes of KTScrollable. The function returns string as a unique identifier for the registered listener, allowing you to remove it later if needed.
off(eventName, eventId) Removes an event listener for the eventName and eventId parameters attached with the on method.
dispose() Removes the KTScrollable instance from an element, including any associated data stored on the DOM element.
				
					const scrollableEl = document.querySelector('#my_scrollable');
const scrollable = KTScrollable.getInstance(scrollableEl);

const height = scrollable.getHeight();
scrollable.update();