Interaction
Toggle
Toggle

Elements

You can specify elements that listens to event for activation, and targets that gets activated.

The query is inside container, only when specifying elements and targets with id the query is on all the document.

SyntaxDefault / ArgumentsDescription
Optionelements:Query'[data-xt-toggle-element]'Elements query
Optiontargets:Query'[data-xt-toggle-target]'Targets query
OptionelementsInner:Query'false'Inner elements query, they reflect elements activation
OptiontargetsInner:QueryfalseInner targets query, they reflect targets activation
Optionexclude:QueryfalseExclude elements and targets if they matches the query

See slider elements exclude for demo.

Group

If you need to toggle multiple elements or targets with the same element or target assign data-xt-group to elements and the associated targets.

NameExampleDescription
Attributedata-xt-groupdata-xt-group="my-group,another-group"Group or multiple groups on elements and targets
SyntaxDefault / ArgumentsDescription
OptiongroupSeparator:String','Separator for multiple groups

You can disable same group elements activation with the option groupElements: false.

SyntaxDefault / ArgumentsDescription
OptiongroupElements:BooleantrueElements activation as group

It also work on unique mode with the same targets.

Class

You can style and animate class names used by the component.

SyntaxDefault / ArgumentsDescription
Optionclass:StringonClass name for activation
OptionclassIn:StringinClass name for in animation
OptionclassOut:StringoutClass name for out animation
OptionclassDone:StringdoneClass name for in animation done
OptionclassInitial:StringinitialClass name for initialization
OptionclassBefore:Stringdir-beforeClass name for before direction activation
OptionclassAfter:Stringdir-afterClass name for after direction activation
OptionclassSkip:ObjectfalseSkip class activation and deactivation, can be one or more booleans e.g.: { elements: true, elementsInner: true, targets: true, targetsInner: true }

You can set initial activation by adding on to the elements or targets, class activation has precedence over automatic activation of min and max.

If initial activation is on a target with multiple groups it activates elements with at least one of the groups and in DOM order.

Additionally on component initialization the attribute [data-xt-toggle-init] gets added to the object.

Quantity

You can specify min and max concurrent activations. The min option is fulfilled on initialization, the max options deactivates the first activated when max is reached.

SyntaxDefault / ArgumentsDescription
Optionmin:Number0Minimum number of concurrent elements activated
Optionmax:Number1Maximum number of concurrent elements activated

data-xt-group additional elements aren't counted for min and max.

Event

You can specify on and off events for the toggle.

SyntaxDefault / ArgumentsDescription
Optionon:String|false'click'List of space separated events to listen for activation
Optionoff:String|false'click'List of space separated events to listen for deactivation
OptionmouseParent:String|BooleanfalseFor mouse events use element parentNode or closest query

When using 'mouseenter', 'mouseleave', 'mousehover', 'mouseout' and you want to interact with the targets you need to use mouseParent: true or mouseParent: '<Query>' to attach mouse events on a element's parent node that contains also the target node. Non mouse events are attached on elements as usual.

For accessibility purpose instead of on: 'mouseenter' use on: 'mouseenter focus' to be navigable with keyboard.

If you have links on elements use preventEvent: true, and the link will trigger only on the second interaction (the first it the on event), works with mouse click, touch press and keyboard enter.

SyntaxDefault / ArgumentsDescription
OptionpreventEvent:BooleanfalsePrevent links on elements or other interactions until activated.

There some other event options.

SyntaxDefault / ArgumentsDescription
OptioneventLimit:Query'.xt-event-limit'Block on and off events inside selector
Optionopenauto:BooleanfalseTrigger the event openauto.trigger.xt inside elements or targets to automatically activate openauto: true
Optioncloseauto:BooleanfalseTrigger the event closeauto.trigger.xt on window to automatically deactivate current activation if closeauto: true
OptioncloseDeep:QueryfalseQuery Node inside elements or targets to deactivate on click (also nested, can be a inner node)
OptioncloseInside:QueryfalseQuery Node inside elements or targets to deactivate on click (no nested, must be exactly that node)
OptioncloseOutside:QueryfalseQuery Node on document to deactivate on click (automatically excludes nested inside elements and targets)

Hash

You can link the activation in the url hash to be linkable and more usable, hash activation has precedence over class activation.

Hash attribute data-xt-hash can be on elements or targets, also hash activates on hash location change.

SyntaxDefault / ArgumentsDescription
Optionhash:String|false[data-xt-hash]Link activation in location hash using elements and targets attribute hash value

Try the demo on a new page to preview location hash changes.

Navigation and Loop

You can add navigation with navigation: '[data-xt-nav]' option, then with [data-xt-nav="value"] to set the amount to add (+1) or remove (-1) to the current activation index.

SyntaxDefault / ArgumentsDescription
Optionnavigation:QueryfalseQuery for navigation elements

You can make the activation loop with loop: true.

SyntaxDefault / ArgumentsDescription
Optionloop:BooleanfalseLoop activation

Jump

Use jump: true to enable clicking on a target to jump to them.

SyntaxDefault / ArgumentsDescription
Optionjump:BooleanfalseClicking on targets triggers activation

Auto

SyntaxDefault / ArgumentsDescription
Optionauto.time:NumberfalseAutomatic activation time
Optionauto.initial:BooleantrueAutomatic activation on initial
Optionauto.step:Number1Automatic activation steps
Optionauto.inverse:BooleanfalseAutomatic activation inverse order
Optionauto.pause:Query'a, button'Query inside container that pause automatic on mouseenter
Optionauto.loop:BooleantrueLoop activation beyond start and end

Auto doesn't run if the toggle is display: none. Start it manually when visible using toggle events.

Use the api and listen to events to make auto progress indicators.

Class Body

See overlay class body for more info.

Scrollto

See scrollto toggle for more info.