Default Scrollable
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.
<div class="rounded-lg border p-4 scrollable h-[300px]">
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
</div>
Hover
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.
<div class="rounded-lg border p-4 scrollable-hover h-[300px]">
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
</div>
Horizontal
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.
<div class="rounded-lg border p-4 scrollable lg:w-[600px]">
<div class="w-[1000px]">
<p class="mb-3">
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.
</p>
<p>
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.
</p>
</div>
</div>
Both 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.
<div class="rounded-lg border p-4 scrollable lg:w-[600px] h-[300px]">
<div class="w-[1000px]">
<p class="mb-3">
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.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
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.
</p>
</div>
</div>
Auto Height
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.
<div class="scrollable rounded-lg border p-4" 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>
With Modal
scrollable-y
class to the
modal-body
element to enable vertical scrolling within the scrollable body.
<button class="btn btn-primary" data-modal-toggle="#modal_1">
Show Scrollable Modal
</button>
<div class="modal" data-modal="true" id="modal_1">
<div class="modal-content max-w-[600px] top-[10%] max-h-[95%]">
<div class="modal-header">
<h3 class="modal-title">
Scrollable Title
</h3>
<button class="btn btn-xs btn-icon btn-icon-xl btn-light" data-modal-dismiss="true">
<i class="ki-outline ki-cross">
</i>
</button>
</div>
<div class="modal-body scrollable-y py-0 my-5 pl-6 pr-3 mr-3 h-[300px] max-h-[95%]">
Scrollable components are commonly used for various purposes such as displaying login forms,
confirming actions, presenting multimedia content, or showing detailed information.
They provide a non-intrusive way to engage users and guide them through
specific tasks or actions while maintaining the context of the underlying webpage.
</div>
<div class="modal-footer justify-end">
<div class="flex gap-4">
<button class="btn btn-light" data-modal-dismiss="true">
Cancel
</button>
<button class="btn btn-primary">
Submit
</button>
</div>
</div>
</div>
</div>
With Card
scrollable-y
class to the
card-body
element
to enable vertical scrolling within the scrollable card.
Card Title
<div class="card">
<div class="card-header">
<h3 class="card-title">
Card Title
</h3>
</div>
<div class="card-body scrollable h-[200px] py-0 my-4 pr-4 mr-2">
<div class="mb-4">
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
</div>
<div>
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
</div>
</div>
<div class="card-footer">
Card Footer
</div>
</div>
Customization
--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.
<div class="rounded-lg border p-4 scrollable h-[300px]" style="--tw-scrollbar-thumb-color: var(--tw-success)">
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
<p class="mb-3">
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.
</p>
</div>
Source Code
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
<div class="scrollable h-[300px]">
Content goes here...
</div>
Classes
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
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>
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
// 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);
<div class="scrollable-y" data-scrollable="false">
Content goes here...
</div>
To initialize the scrollable with JavaScript, use
data-scrollable="false"
attribute instead.
This prevents automatic initialization on page load.
Options
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
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);
<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>
Methods
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();
<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>