ΤΜΗΜΑΤΑ ΥΠΟΔΟΜΗΣ...

Timepicker

Create a timepicker which can easily be used by selecting a time value from a pre filled dropdown.

Usage

To apply the timepicker, just add the data-uk-timepicker attribute to an <input> element. The timepicker will automatically display a pre filled dropdown on focus, which can be navigated by pressing the up or down button on the keyboard or by scrolling with the mouse.

IMPORTANT The timepicker component requires the Autocomplete component in order to work. Please make sure that you always include them together.

Example

Markup

<form class="uk-form">
    <input type="text" data-uk-timepicker>
</form>

Display meridian time

To display meridian time, just define the format option and set it to 12h

Example

Markup

<form class="uk-form">
    <input type="text" data-uk-timepicker="{format:'12h'}">
</form>

JavaScript options

This is an example of how to set options via data attribute:

data-uk-timepicker="{format:'12h'}"
Option Possible value Default Description
format '24h' or '12h' '24h' Defines the preferred time notation
start Integer between 0 and 24 0 Start time
end Integer between 0 and 24 24 End time

Init element manually

var timepicker = UIkit.timepicker(element, { /* options */ });

Datepicker

Create a toggleable dropdown with an datepicker.

Usage

To create a datepicker, just add the data-uk-datepicker attribute to an <input> element. You also have the possibility of customizing the date format. Just add the format option to the data-uk-datepicker attribute.

The datepicker detects whether the JavaScript from the Form select component is being loaded. This allows you to quickly toggle between years and months through a select form inside the datepicker.

Example

Markup

<form class="uk-form">
    <input type="text" data-uk-datepicker="{format:'DD.MM.YYYY'}">
</form>

JavaScript options

This is an example of how to set options via attribute:

data-uk-datepicker="{weekstart:0, format:'DD.MM.YYYY'}"
Option Possible value Default Description
weekstart integer (0..6) 1 Start of the week
i18n JSON object { months:['January',...], weekdays:['Sun',..,'Sat'] } Language string definitions
format any combination of DD, MM and YYYY 'YYYY-MM-DD' Date format string
offsettop integer 5 Offset to the input value
minDate bool (false to ignore the option)
string (date as in format)
integer (offset in days from current date)
false Min. date
maxDate bool (false to ignore the option)
string (date as in format)
integer (offset in days from current date)
false Max. date
pos 'auto', 'top', 'bottom' 'auto' Position of the datepicker

Init element manually

var datepicker = UIkit.datepicker(element, { /* options */ });

Events

Name Parameter Description
show.uk.datepicker event On datepicker dropdown show
hide.uk.datepicker event On datepicker dropdown hide
update.uk.datepicker event On calendar rendering

Tooltip

Easily create a nicely looking tooltip.

Usage

To apply this component, add the data-uk-tooltip attribute to an element. You also need to add a title attribute, whose value will represent your tooltip's text.

Example

Hover me

Markup

<button class="uk-button" data-uk-tooltip title="">...</button>
<span data-uk-tooltip title="">...</span>

Alignment

Add one of the following options to the data-uk-tooltip attribute to adjust the tooltip's alignment.

Attribute Description Example
pos:'top' Aligns the tooltip to the top.
pos:'top-left' Aligns the tooltip to the top left.
pos:'top-right' Aligns the tooltip to the top right.
pos:'bottom' Aligns the tooltip to the bottom.
pos:'bottom-left' Aligns the tooltip to the bottom left.
pos:'bottom-right' Aligns the tooltip to the bottom right.
pos:'left' Aligns the tooltip to the left.
pos:'right' Aligns the tooltip to the right.

Markup

<button class="uk-button" data-uk-tooltip="{pos:'bottom-left'}" title="">...</button>

JavaScript options

This is an example of how to set options via attribute:

data-uk-tooltip="{pos:'bottom-left'}"
Option Possible value Default Description
offset integer 5 Offset to the source element
pos string 'top' Tooltip position
animation boolean false Fade in tooltip
delay integer 0 Delay tooltip show in ms
cls string '' Custom class to add on show
activeClass string 'uk-active' Toggled active class

Sticky

Make elements remain at the top of the viewport, like a sticky navbar.

Usage

To create an element that remains at the top of the viewport when scrolling down the site, add the data-uk-sticky attribute to that element.

Example

Stick to the top

Markup

<div data-uk-sticky>...</div>

Define an offset

You can also position the element below the viewport edge. For example, add the data-uk-sticky="{top:100}" attribute to create a margin of 100px.

Example

Stick 100px below the top

Markup

<div data-uk-sticky="{top:100}">...</div>

Add a delay

To add a delay to the element, so it becomes sticky only after scrolling a specified distance, you need to add a negative offset to the data attribute, e.g. data-uk-sticky="{top:-200}". You can also add an animation from the Animation component in order to have the sticky element reappear smoothly.

Example

Stick at the top but only after 100px scrolling

Markup

<div data-uk-sticky="{top:-200, animation: 'uk-animation-slide-top'}">...</div>

Responsive behavior

You also have the possibility of disabling the sticky behavior for different devices by adding a breakpoint option to the data attribute, e.g. data-uk-sticky="{media: 640}". Additionaly you can use any valid media query.

Markup

<!-- This is basically a shortcode to define a min-width -->
<div data-uk-sticky="{media: 640}">...</div>

<!-- This is a media string using the min-width and orientation properties -->
<div data-uk-sticky="{media: '(min-width: 640px) and (orientation: landscape)'}>...</div>

Sticky boundary

You can define the boundary of a sticky element by setting the boundary parameter. This keeps the sticky element within the dimensions of the boundary element.

Example

Sticky bound to parent container
Sticky as long as bondary element is in view
Boundary element

Markup

<!-- Bind sticky to its parent element -->
<div data-uk-sticky="{boundary: true}">...</div>

<!-- Bind sticky to any element -->
<div data-uk-sticky="{boundary: '#my-id'}">...</div>

JavaScript options

Option Possible value Default Description
top integer 0 Top offset whent sticky should be triggered
animation string '' UIkit animation class
clsinit string uk-sticky-init Init class when the element is sticky for the first time
clsactive string uk-active Active class to add, when element is sticky
clsinactive string '' Class to add, when element is not sticky
getWidthFrom string '' Css selector where to get the width from in sticky mode. By default it takes the width from the created wrapper element.
media integer / string false Condition for the active status with a width as integer (e.g. 640) or a css media query
target boolean false Make sure that a sticky element is not over a targeted element via location hash on dom-ready.
showup boolean false Show sticky element only when scrolling up.
boundary mixed false Set to true to bind sticky to the parent or a Css selector to bind sticky to a specific element.

Init element manually

var sticky = UIkit.sticky(element, { /* options */ });

Events

Name Parameter Description
active.uk.sticky event Element getting sticky
inactive.uk.sticky event Element leaving sticky mode

Parallax

Animate CSS properties depending on the scroll position of the document.

Usage

To apply this component, add the data-uk-parallax attribute to a container element. Add an option with the desired animation target value for each CSS property you want to animate.

Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Markup

<div data-uk-parallax="{bg: '-200'}">...</div>

Options

UIkit provides a number of options that you can add to the data-uk-parallax attribute:

Option Description
x Animate translateX in pixels.
xp Animate translateX in percent.
y Animate translateY in pixels.
yp Animate translateY in percent.
bg Animate a background image.
bgp Animate a background image in percent.
rotate Animate rotation clockwise in degree.
scale Animate scaling.
color Animate color (needs start and stop value).
background-color Animate background-color (needs start and stop value).
border-color Animate border color (needs start and stop value).
opacity Animate the opacity.

NOTE You can basically animate any CSS property that has a single value, like width and height, by adding it to the attribute.

Markup

<div data-uk-parallax="{y: '-200', opacity: '0'}">...</div>

Start and stop values

Properties are always animated from the current value to the target value which you set in the option. However, you can also define a start value yourself. This is done by passing a string to the option which contains two values separated by comma.

NOTE Some properties, like colors, require a start and a stop value!

Markup

<div data-uk-parallax="{x: '-100,100', 'background-color': '#EBF7FD,#FFF1F0'}">...</div>

Nested animation

Using different animations for nested elements is a simple task. Just create another container within the first parallax container and add your options to a new data-uk-parallax attribute.

Example

Heading

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Markup

<div data-uk-parallax="{bg: -200}">
    <div data-uk-parallax="{opacity: '0,1', scale: '0,1'}">...</div>
</div>

Target Option

Usually, the animation lasts as long as the element itself is in the viewport. To start and stop the animation based on the viewport visibility of another element, use the target option. This can be helpful when using nested animations.

Example

Heading

This text is animated as long as the headline "Target Option" is in the viewport.

Markup

<div id="target-id">...</div>
<div data-uk-parallax="{target: '#target-id'}">...</div>

Velocity

To adjust the easing of the animation, add the velocity option.

Example

0.04
0.2
0.6
1
2
3
4

Markup

<div data-uk-parallax="{velocity: '0.5'}">
    ...
</div>

Viewport

Using the viewport option, the animation duration can be adjusted. With the value 1 or false the animation lasts as long as the element is in the viewport. Setting it to 0.5, for example, animates the property only in the first half of the viewport.

Example

Heading

This text is animated until it reaches the middle of the viewport.

Markup

<div data-uk-parallax="{viewport: '0.5'}">...</div>

JavaScript options

Option Possible value Default Description
velocity float 0.5 Animation velocity during scrolling
target mixed false Element dimension reference for animation duration.
viewport float (0 to 1) false Animation range depending on the viewport.
media integer / string false Condition for the active status with a width as integer (e.g. 640) or a css media query

Init element manually

var parallax = UIkit.parallax(element, { /* options */ });

Περισσότερα Άρθρα...

Αυτός ο ιστότοπος χρησιμοποιεί cookies και σε ορισμένες περιπτώσεις cookies τρίτων μερών για σκοπούς μάρκετινγκ και για την παροχή βελτιωμένων υπηρεσιών σύμφωνα με τις προτιμήσεις σας. Κάνοντας κλικ στο OK ή συνεχίζοντας την περιήγησή σας στον ιστότοπό μας, αποδέχεστε την χρήση cookies σύμφωνα με τη σχετική πολιτική μας.
Μάθε περισσότερα ΟΚ