Overview
Tiny-slider provides a comprehensive set of options to customize slider behavior. Options are passed to thetns() function during initialization.
Option Categories
- Container & Layout
- Display & Items
- Navigation Controls
- Navigation Dots
- Autoplay
- Animation & Mode
- Interaction
- Responsive
- Advanced
Container & Layout
The slider container element or selector.
Controls animation behavior:
carousel: Slides move to the sidegallery: Uses fade animations, changes all slides at once
The axis of the slider.
Space on the outside (in pixels).
Center the active slide in the viewport.
Available from v2.9.2+
Display & Items
Number of slides being displayed in the viewport.
Space between slides (in pixels).
Controls width attribute of the slides. When set, each slide will have this fixed width in pixels.
Sets the width of slides to auto. If true, the width of each slide will be its natural width as an inline-block box.
Height of slider container changes according to each slide’s height.
Navigation Controls
Controls the display and functionalities of controls components (prev/next buttons). If true, display the controls and add all functionalities.
Text or markup in the prev/next buttons.
The container element/selector around the prev/next buttons.
Customized previous button.
This option will be ignored if controlsContainer is a Node element or a CSS selector.
Customized next button.
This option will be ignored if controlsContainer is a Node element or a CSS selector.
Navigation Dots
Controls the display and functionalities of nav components (dots). If true, display the nav and add all functionalities.
Controls nav position.
The container element/selector around the dots.
Indicate if the dots are thumbnails. If true, they will always be visible even when more than 1 slide displayed in the viewport.
Autoplay
Toggles the automatic change of slides.
Time between 2 autoplay slides change (in milliseconds).
Direction of slide movement (ascending/descending the slide index).
Text or markup in the autoplay start/stop button.
Stops sliding on mouseover.
The customized autoplay start/stop button or selector.
Output autoplayButton markup when autoplay is true but a customized autoplayButton is not provided.
Pauses the sliding when the page is invisible and resumes it when the page becomes visible again (Page Visibility API).
Animation & Mode
Speed of the slide animation (in milliseconds).
Name of intro animation class (for gallery mode).
Name of outro animation class (for gallery mode).
Name of default animation class.
Time between each gallery animation (in milliseconds).
Moves throughout all the slides seamlessly.
Moves to the opposite edge when reaching the first or last slide.
Number of slides going on one “click”.
The initial index of the slider.
Interaction
Activates input detection for touch devices.
Changing slides by dragging them with mouse.
Allows using arrow keys to switch slides.
Swipe or drag will not be triggered if the angle is not inside the range when set.
Prevent next transition while slider is transforming.
Available from v2.9.1+
Prevent page from scrolling on touchmove:
auto: Check if touch direction matches slider axis firstforce: Always prevent page scrollingfalse: Don’t prevent scrolling
Available from v2.9.1+
Responsive
Defines options for different viewport widths. Breakpoints behave like See Responsive Options for available options.
(min-width: breakpoint) in CSS.Advanced
Enables lazyloading images that are currently not viewed, thus saving bandwidth.Requires:
- Class matching
lazyloadSelectoron images data-srcattribute with real image srcwidthattribute forautoWidthslider
The CSS selector for lazyload images.
Available from v2.9.1+
Define the relationship between nested sliders.
Indicate whether the slider will be frozen (controls, nav, autoplay and other functions will stop work) when all slides can be displayed in one page.
Disable slider.
Save browser capability variables to localStorage and without detecting them every time the slider runs.
Nonce attribute for inline style tag to allow slider usage without unsafe-inline Content Security Policy source.
Callback to be run on initialization.
Responsive Options Interface
The following options can be redefined in theresponsive field:
| Option | Type | Description |
|---|---|---|
startIndex | number | Initial slide index |
items | number | Number of visible slides |
slideBy | number | ‘page’ | Slides to move per action |
speed | number | Animation speed |
autoHeight | boolean | Dynamic container height |
fixedWidth | number | false | Fixed slide width |
edgePadding | number | Outside spacing |
gutter | number | Space between slides |
center | boolean | Center active slide |
controls | boolean | Show/hide controls |
controlsText | string[] | Control button text |
nav | boolean | Show/hide nav dots |
autoplay | boolean | Enable/disable autoplay |
autoplayHoverPause | boolean | Pause on hover |
autoplayResetOnVisibility | boolean | Reset on visibility change |
autoplayText | string[] | Autoplay button text |
autoplayTimeout | number | Time between slides |
touch | boolean | Touch input detection |
mouseDrag | boolean | Mouse drag support |
arrowKeys | boolean | Arrow key navigation |
disable | boolean | Disable slider |
Responsive Behavior
The breakpoints behave like
(min-width: breakpoint) in CSS, so an undefined option will be inherited from previous small breakpoints.Complete Options Table
| Option | Type | Default | Description |
|---|---|---|---|
container | HTMLElement | Element | string | .slider | Slider container |
mode | carousel | gallery | carousel | Animation mode |
axis | horizontal | vertical | horizontal | Slider axis |
items | number | 1 | Visible slides |
gutter | number | 0 | Space between slides (px) |
edgePadding | number | 0 | Outside space (px) |
fixedWidth | number | false | false | Fixed slide width |
autoWidth | boolean | false | Auto slide width |
autoHeight | boolean | false | Dynamic height |
center | boolean | false | Center active slide |
controls | boolean | true | Show controls |
controlsText | string[] | ['prev', 'next'] | Control text |
controlsContainer | HTMLElement | string | false | false | Custom controls container |
prevButton | HTMLElement | string | false | false | Custom prev button |
nextButton | HTMLElement | string | false | false | Custom next button |
nav | boolean | true | Show navigation dots |
navPosition | top | bottom | top | Nav position |
navContainer | HTMLElement | string | false | false | Custom nav container |
navAsThumbnails | boolean | false | Use thumbnails |
arrowKeys | boolean | false | Arrow key navigation |
speed | number | 300 | Animation speed (ms) |
autoplay | boolean | false | Auto slide change |
autoplayTimeout | number | 5000 | Autoplay interval (ms) |
autoplayDirection | forward | backward | forward | Autoplay direction |
autoplayText | string[] | ['start', 'stop'] | Autoplay button text |
autoplayHoverPause | boolean | false | Pause on hover |
autoplayButton | HTMLElement | string | false | false | Custom autoplay button |
autoplayButtonOutput | boolean | true | Output autoplay button |
autoplayResetOnVisibility | boolean | true | Reset on visibility |
animateIn | string | tns-fadeIn | Intro animation class |
animateOut | string | tns-fadeOut | Outro animation class |
animateNormal | string | tns-normal | Default animation class |
animateDelay | number | false | false | Gallery animation delay (ms) |
loop | boolean | true | Seamless loop |
rewind | boolean | false | Rewind at edges |
slideBy | number | page | 1 | Slides per action |
startIndex | number | 0 | Initial slide |
responsive | ResponsiveOptions | false | false | Responsive config |
lazyload | boolean | false | Enable lazy loading |
lazyloadSelector | string | .tns-lazy-img | Lazy load selector |
touch | boolean | true | Touch detection |
mouseDrag | boolean | false | Mouse drag support |
swipeAngle | number | boolean | 15 | Swipe angle threshold |
preventActionWhenRunning | boolean | false | Prevent actions during transition |
preventScrollOnTouch | auto | force | false | false | Prevent page scroll |
nested | inner | outer | false | false | Nested slider mode |
freezable | boolean | true | Freeze when all visible |
disable | boolean | false | Disable slider |
useLocalStorage | boolean | true | Cache capabilities |
nonce | string | false | false | CSP nonce |
onInit | Function | false | false | Init callback |