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

More Articles ...

Chameleon I.T are a client focused consultancy seeking to deliver IT efficiency gains through software and consulting solutions.

These solutions seek to take existing systems and optimise them in conjunction with adding cutting edge technologies to complement.

 

Map

Contact us

Phone:
01727 831 383
Email:
info@chameleonit.co.uk
Mon-Fri:
9am to 5pm

Search