Pattern Browser

125 patterns with 125 translations across 1 languages. Search and filter to find the code you need.

Both _hyperscript LokaScript Unverified
Showing 125 of 125 patterns
Accessible Tabs ui-components

Tab navigation with ARIA attributes

on click set @aria-selected to "false" on .tab set @aria-selected to "true" on me
1 translations
Loading...
Accordion Toggle ui-components

Toggle accordion panel visibility

on click toggle .open on closest .accordion-item toggle @aria-expanded
1 translations
Loading...
Add Class class-manipulation

Add a CSS class to the current element when clicked

on click add .highlight to me
1 translations
Loading...
Add Class To Other class-manipulation

Add a CSS class to another element

on click add .selected to #item
1 translations
Loading...
Append Content dom-manipulation

Append content to an element

on click append "<li>Item</li>" to #list
1 translations
Loading...
Async Block advanced

Execute commands asynchronously

on click async fetch /api/data then put it into me
1 translations
Loading...
AutoDismiss Behavior behavior

Auto-removes element after a delay (toast/flash). Use: install AutoDismiss(delay: 3000, effect: "fade")

behavior AutoDismiss(delay, pauseOnHover, effect) init if delay is undefined set delay to 5000 end if pauseOnHover is undefined set pauseOnHover to true end if effect is undefined set effect to "none" end js(me, delay, effect, pauseOnHover) me.dispatchEvent(new CustomEvent('autodismiss:start', { bubbles: true })); var remaining = delay; var startedAt = Date.now(); var timerId = null; function dismiss() { var ev = new CustomEvent('autodismiss:dismissed', { bubbles: true, cancelable: true }); me.dispatchEvent(ev); if (ev.defaultPrevented) return; if (effect === 'fade') { me.style.transition = 'opacity 300ms'; me.style.opacity = '0'; setTimeout(function() { me.remove(); }, 300); } else { me.remove(); } } function start() { startedAt = Date.now(); timerId = setTimeout(dismiss, remaining); } start(); if (pauseOnHover) { me.addEventListener('mouseenter', function() { if (timerId != null) { clearTimeout(timerId); timerId = null; remaining -= Date.now() - startedAt; if (remaining < 0) remaining = 0; me.dispatchEvent(new CustomEvent('autodismiss:paused', { bubbles: true })); } }); me.addEventListener('mouseleave', function() { if (timerId == null && me.isConnected) { me.dispatchEvent(new CustomEvent('autodismiss:resumed', { bubbles: true })); start(); } }); } end end end
1 translations
Loading...
Blur Element focus

Remove focus from element

on keydown[key=="Escape"] blur me
1 translations
Loading...
Call Function advanced

Call a JavaScript function

on click call myFunction()
1 translations
Loading...
Chained Property Access (Possessive Dot) lokascript hyperfixi-extensions

Chained property access using possessive dot notation (HyperFixi extension)

on click set my.parentElement.style.display to "none"
1 translations
Loading...
Character Counter forms

Show character count as user types

on input set #count.innerText to my value.length
1 translations
Loading...
Clear Input forms

Clear the previous input field

on click set previous <input/>.value to ""
1 translations
Loading...
Click Elsewhere events

Handle clicks outside element

on click from elsewhere remove .open from me
1 translations
Loading...
ClickOutside Behavior behavior

Fires clickoutside event when user clicks outside the element. Use: install ClickOutside

behavior ClickOutside(active) init if active is undefined set active to true end end on pointerdown from document js(me, active) if (!me.isConnected) return; if (active && !me.contains(event.target)) { me.dispatchEvent(new CustomEvent('clickoutside', { bubbles: true })); } end end on clickoutside:activate set active to true end on clickoutside:deactivate set active to false end end
1 translations
Loading...
Clipboard Behavior behavior

Copies text to clipboard on click with visual feedback. Use: install Clipboard(source: "#code-snippet")

behavior Clipboard(text, source, feedback, feedbackDuration) init if feedbackDuration is undefined set feedbackDuration to 2000 end if source is undefined set source to me end end on click if text is not undefined set copyText to text else set copyText to source's textContent end js(me, copyText, feedback, feedbackDuration) async function copyToClipboard(t) { if (navigator.clipboard && navigator.clipboard.writeText) { await navigator.clipboard.writeText(t); return; } var ta = document.createElement('textarea'); ta.value = t; ta.style.position = 'fixed'; ta.style.opacity = '0'; document.body.appendChild(ta); ta.select(); try { document.execCommand('copy'); } finally { document.body.removeChild(ta); } } try { await copyToClipboard(copyText); var feedbackEl = feedback ? (typeof feedback === 'string' ? document.querySelector(feedback) : feedback) : me; if (!feedbackEl) feedbackEl = me; feedbackEl.classList.add('copied'); me.dispatchEvent(new CustomEvent('clipboard:copied', { bubbles: true, detail: { text: copyText } })); setTimeout(function() { feedbackEl.classList.remove('copied'); }, feedbackDuration); } catch(err) { me.dispatchEvent(new CustomEvent('clipboard:error', { bubbles: true, detail: { error: err } })); } end end end
1 translations
Loading...
Close Dropdown On Outside Click ui-components

Close dropdown when clicking outside

on click from elsewhere remove .open from .dropdown-menu
1 translations
Loading...
Close Modal Button ui-components

Close modal from button inside

on click hide closest .modal remove .modal-open from body
1 translations
Loading...
Close Modal On Backdrop Click ui-components

Close modal by clicking outside

on click if target matches .modal-backdrop hide .modal-backdrop end
1 translations
Loading...
Close Modal On Escape ui-components

Close modal when pressing Escape key

on keydown[key=="Escape"] from window hide .modal remove .modal-open from body
1 translations
Loading...
Closest Ancestor navigation

Toggle class on closest matching ancestor

on click toggle .expanded on closest .card
1 translations
Loading...
Computed Value data

Calculate and display computed value

on input from .quantity set #total.innerText to (the value of #price as Number) * (my value as Number)
1 translations
Loading...
Copy To Clipboard clipboard

Copy text to clipboard with feedback

on click call navigator.clipboard.writeText(#code.innerText) put "Copied!" into me wait 2s put "Copy" into me
1 translations
Loading...
Decrement Counter counters

Decrement a numeric counter element

on click decrement #counter
1 translations
Loading...
Default Value data

Set default value if not present

on load default my @data-count to "0"
1 translations
Loading...
Disable Form On Submit forms

Disable submit button while processing

on submit add @disabled to <button/> in me put "Submitting..." into <button/> in me
1 translations
Loading...
Document Ready window-events

Initialize app when element loads

on load call initializeApp()
1 translations
Loading...
Draggable Behavior behavior

Makes element draggable with pointer events. Use: install Draggable(dragHandle: ".titlebar")

behavior Draggable(dragHandle) init if no dragHandle set dragHandle to me end on pointerdown(clientX, clientY) from dragHandle halt the event trigger draggable:start measure x set startX to it measure y set startY to it set xoff to clientX - startX set yoff to clientY - startY repeat until event pointerup from document wait for pointermove(clientX, clientY) or pointerup(clientX, clientY) from document add { left: ${clientX - xoff}px; top: ${clientY - yoff}px; } trigger draggable:move end trigger draggable:end end end
1 translations
Loading...
Dropdown Toggle ui-components

Toggle dropdown menu visibility

on click toggle .open on next .dropdown-menu halt
1 translations
Loading...
Event Debounce events

Debounce input for search

on input debounced at 300ms fetch /api/search?q=${my value} as json then put it into #results
1 translations
Loading...
Event Once events

Handle event only once

on click once add .initialized to me call setup()
1 translations
Loading...
Event Throttle events

Throttle scroll handler

on scroll throttled at 100ms call updateScrollPosition()
1 translations
Loading...
Exclusive Accordion ui-components

Accordion where only one panel is open

on click remove .open from .accordion-item add .open to closest .accordion-item
1 translations
Loading...
Fade Out And Remove animation

Fade element out then remove from DOM

on click transition opacity to 0 over 300ms then remove me
1 translations
Loading...
Fetch Data async

Fetch data from an API and display it

on click fetch /api/data then put it into #result
1 translations
Loading...
Fetch JSON async

Fetch JSON data and use a property

on click fetch /api/user as json then set #name.innerText to it.name
1 translations
Loading...
Fetch With Error Handling async

Handle API errors by checking response body

on click fetch /api/data as json then if it.error put it.error into #error else put it.data into #result end
1 translations
Loading...
Fetch With Loading State async

Show loading indicator during fetch

on click add .loading to me fetch /api/data then remove .loading from me put it into #result
1 translations
Loading...
Fetch With Method async

Submit form data via POST

on submit fetch /api/form with method:"POST" body:form
1 translations
Loading...
First In Collection navigation

Focus first input in parent form

on click focus first <input/> in closest <form/>
1 translations
Loading...
Focus Element focus

Focus an input element

on click focus #input
1 translations
Loading...
Focus Trap accessibility

Trap focus within modal

on keydown[key=="Tab"] from .modal if target matches last <button/> in .modal focus first <button/> in .modal halt end
1 translations
Loading...
FocusTrap Behavior behavior

Confines Tab navigation inside an element with ARIA support. Use: install FocusTrap(initialFocus: "#first-input")

behavior FocusTrap(active, initialFocus, returnFocus) init if active is undefined set active to true end if returnFocus is undefined set returnFocus to true end js(me, active, initialFocus, returnFocus) var FOCUSABLE = 'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex="-1"])'; var isActive = false; var previouslyFocused = null; function getFocusable() { return Array.from(me.querySelectorAll(FOCUSABLE)); } function activate() { if (isActive) return; isActive = true; previouslyFocused = document.activeElement; me.setAttribute('aria-modal', 'true'); var initEl = initialFocus ? (typeof initialFocus === 'string' ? me.querySelector(initialFocus) : initialFocus) : null; if (initEl) { initEl.focus(); } else { var f = getFocusable(); if (f.length) f[0].focus(); } me.dispatchEvent(new CustomEvent('focustrap:activated', { bubbles: true })); } function deactivate() { if (!isActive) return; isActive = false; me.removeAttribute('aria-modal'); if (returnFocus && previouslyFocused instanceof HTMLElement) previouslyFocused.focus(); previouslyFocused = null; me.dispatchEvent(new CustomEvent('focustrap:deactivated', { bubbles: true })); } me.addEventListener('keydown', function(e) { if (!isActive || e.key !== 'Tab') return; var focusable = getFocusable(); if (focusable.length === 0) { e.preventDefault(); return; } e.preventDefault(); var idx = focusable.indexOf(document.activeElement); if (e.shiftKey) { focusable[idx <= 0 ? focusable.length - 1 : idx - 1].focus(); } else { focusable[idx >= focusable.length - 1 ? 0 : idx + 1].focus(); } }); me.addEventListener('focustrap:activate', function() { activate(); }); me.addEventListener('focustrap:deactivate', function() { deactivate(); }); if (active) activate(); end end end
1 translations
Loading...
Get Attribute (Possessive Dot) lokascript hyperfixi-extensions

Call getAttribute using possessive dot notation (HyperFixi extension)

on click put my.getAttribute("data-id") into #output
1 translations
Loading...
Get Input Value (Possessive Dot) lokascript hyperfixi-extensions

Mirror input value using possessive dot notation (HyperFixi extension)

on input put my.value into #preview
1 translations
Loading...
Get Value data

Get a value and use it

on click get #input.value then log it
1 translations
Loading...
Go Back navigation

Navigate back in history

on click go back
1 translations
Loading...
Go To URL navigation

Navigate to a URL

on click go to url "/page"
1 translations
Loading...
Halt Event control-flow

Stop event propagation

on click halt the event then toggle .active
1 translations
Loading...
Hide Element visibility

Hide an element

on click hide #modal
1 translations
Loading...
Hide With Transition visibility

Hide element with opacity transition

on click hide me with *opacity
1 translations
Loading...
If Condition control-flow

Conditional execution based on state

on click if I match .active then remove .active else add .active end
1 translations
Loading...
If Element Exists control-flow

Check if element exists before action

on click if #modal exists show #modal else make a <div#modal/> put it into body end
1 translations
Loading...
If Matches Selector control-flow

Check if element matches selector

on click if I match .disabled halt else toggle .active end
1 translations
Loading...
If Value Empty control-flow

Validate empty input

on blur if my value is empty add .error to me put "Required" into next .error-message end
1 translations
Loading...
Increment By Amount counters

Increment counter by specific amount

on click increment #score by 10
1 translations
Loading...
Increment Counter counters

Increment a numeric counter element

on click increment #counter
1 translations
Loading...
Inline JavaScript advanced

Execute inline JavaScript

on click js console.log("from js") end
1 translations
Loading...
Input Mirror forms

Mirror input value to another element

on input put my value into #preview
1 translations
Loading...
Input Validation forms

Validate input on blur

on blur if my value is empty add .error to me else remove .error from me end
1 translations
Loading...
Install Behavior behaviors

Install a reusable behavior on an element. Replace "Draggable" with any defined behavior name (e.g., Sortable, Closeable).

install Draggable
1 translations
Loading...
Its Value (Possessive Dot) lokascript hyperfixi-extensions

Access result property using its.property syntax (HyperFixi extension)

on click fetch /api/data then put its.name into #result
1 translations
Loading...
Key Combination events

Handle Shift+Enter key combo

on keydown[key=="Enter"] if event.shiftKey call submitAndContinue() end
1 translations
Loading...
Last In Collection navigation

Scroll to last message in chat

on click scroll to last <.message/> in #chat
1 translations
Loading...
Log Element debugging

Log the current element to console

on click log me
1 translations
Loading...
Log Value debugging

Log a message to the console

on click log "Button clicked!"
1 translations
Loading...
Make Element dom-manipulation

Create a new element dynamically

on click make a <div.card/> then put it into #container
1 translations
Loading...
Method Call (Possessive Dot) lokascript hyperfixi-extensions

Call method on property using possessive dot notation (HyperFixi extension)

on input put my.value.toUpperCase() into #preview
1 translations
Loading...
Multiple Event Handlers events

Handle multiple events with one handler

on click or keypress[key=="Enter"] toggle .active
1 translations
Loading...
Next Element navigation

Select and modify next sibling element

on click add .highlight to next <li/>
1 translations
Loading...
Open Modal ui-components

Open modal and prevent body scroll

on click show #modal add .modal-open to body
1 translations
Loading...
Optional Chaining (Possessive) lokascript hyperfixi-extensions

Safe property access using optional chaining (HyperFixi extension)

on click log my?.dataset?.customValue
1 translations
Loading...
Prevent Form Submit forms

Prevent form submission and validate

on submit halt the event call validateForm() if result is false log "Invalid form" end
1 translations
Loading...
Previous Element navigation

Select and modify previous sibling element

on click remove .highlight from previous <li/>
1 translations
Loading...
Put After dom-manipulation

Insert content after the current element

on click put "<p>New</p>" after me
1 translations
Loading...
Put Before dom-manipulation

Insert content before the current element

on click put "<p>New</p>" before me
1 translations
Loading...
Put Content dom-manipulation

Replace the content of the current element

on click put "Done!" into me
1 translations
Loading...
Removable Behavior behavior

Removes element on click with optional confirmation and fade effect. Use: install Removable(confirmRemoval: true, effect: "fade")

behavior Removable(triggerEl, confirmRemoval, effect) init if triggerEl is undefined set triggerEl to me end end on click from triggerEl if confirmRemoval js(me) if (!window.confirm("Are you sure?")) return "cancel"; end if it is "cancel" halt end end trigger removable:before if effect is "fade" transition opacity to 0 over 300ms end trigger removable:removed remove me end end
1 translations
Loading...
Remove Class class-manipulation

Remove a CSS class from the current element when clicked

on click remove .highlight from me
1 translations
Loading...
Remove Class From All class-manipulation

Remove a CSS class from all matching elements

on click remove .active from .items
1 translations
Loading...
Remove Element dom-manipulation

Remove the current element from the DOM

on click remove me
1 translations
Loading...
Repeat For Each loops

Iterate over a collection

on click repeat for item in .items add .processed to item
1 translations
Loading...
Repeat Forever loops

Infinite animation loop

on load repeat forever toggle .pulse wait 1s end
1 translations
Loading...
Repeat Times loops

Repeat an action multiple times

on click repeat 3 times add "<p>Line</p>" to me
1 translations
Loading...
Repeat Until Event loops

Repeat action while button is held

on mousedown repeat until event mouseup increment #counter wait 100ms end
1 translations
Loading...
Repeat While Condition loops

Repeat while condition is true

on click repeat while #counter.innerText < 10 increment #counter wait 200ms end
1 translations
Loading...
Resizable Behavior behavior

Makes elements resizable by dragging. Use: install Resizable(minWidth: 100, minHeight: 100)

behavior Resizable(handle, minWidth, minHeight, maxWidth, maxHeight) init if handle is undefined set handle to me end if minWidth is undefined set minWidth to 50 end if minHeight is undefined set minHeight to 50 end if maxWidth is undefined set maxWidth to 9999 end if maxHeight is undefined set maxHeight to 9999 end end on pointerdown(clientX, clientY) from handle halt the event trigger resizable:start measure width set startWidth to it measure height set startHeight to it set startX to clientX set startY to clientY repeat until event pointerup from document wait for pointermove(clientX, clientY) or pointerup from document js(startWidth, startHeight, clientX, clientY, startX, startY, minWidth, maxWidth, minHeight, maxHeight, me) var nw = Math.max(minWidth, Math.min(maxWidth, startWidth + (clientX - startX))); var nh = Math.max(minHeight, Math.min(maxHeight, startHeight + (clientY - startY))); me.style.width = nw + 'px'; me.style.height = nh + 'px'; end trigger resizable:resize end trigger resizable:end end end
1 translations
Loading...
Resize Handler window-events

Handle window resize with debounce

on resize from window debounced at 200ms call adjustLayout()
1 translations
Loading...
Screen Reader Announcement accessibility

Announce message to screen readers

on success put event.detail.message into #sr-announce set @role to "alert" on #sr-announce
1 translations
Loading...
Scroll Handler window-events

Add sticky class on scroll

on scroll from window if window.scrollY > 100 add .sticky to #header else remove .sticky from #header end
1 translations
Loading...
ScrollReveal Behavior behavior

Reveals element when it enters viewport via IntersectionObserver. Use: install ScrollReveal(cls: "visible", once: true)

behavior ScrollReveal(cls, threshold, once) init if cls is undefined set cls to "revealed" end if threshold is undefined set threshold to 0.1 end if once is undefined set once to true end js(me, cls, threshold, once) var obs = new IntersectionObserver(function(entries) { for (var i = 0; i < entries.length; i++) { if (entries[i].isIntersecting) { me.classList.add(cls); me.dispatchEvent(new CustomEvent('scrollreveal:enter', { bubbles: true })); if (once) obs.disconnect(); } else if (!once) { me.classList.remove(cls); me.dispatchEvent(new CustomEvent('scrollreveal:exit', { bubbles: true })); } } }, { threshold: threshold }); obs.observe(me); end end end
1 translations
Loading...
Send Custom Event events

Dispatch a custom event to another element

on click send refresh to #widget
1 translations
Loading...
Send Event With Detail events

Send an event with data payload

on click send update(value: 42) to #target
1 translations
Loading...
Set Attribute dom-manipulation

Set an attribute on the current element

on click set @disabled to true
1 translations
Loading...
Set CSS Variable css-styles

Set a CSS custom property

on click set the *--primary-color of #theme to "#ff6600"
1 translations
Loading...
Set Opacity css-styles

Set CSS opacity using possessive syntax

on click set my *opacity to 0.5
1 translations
Loading...
Set Style dom-manipulation

Set a CSS style property

on click set my *background to "red"
1 translations
Loading...
Set Text (Possessive Dot) lokascript hyperfixi-extensions

Set text content using possessive dot notation (HyperFixi extension)

on click set my.textContent to "Done!"
1 translations
Loading...
Set Text Content dom-manipulation

Set the text content of an element by ID

on click set #output.innerText to "Hello World"
1 translations
Loading...
Set Transform css-styles

Set CSS transform property

on click set my *transform to "rotate(45deg)"
1 translations
Loading...
Set innerHTML (Possessive Dot) lokascript hyperfixi-extensions

Set innerHTML using possessive dot notation (HyperFixi extension)

on click set my.innerHTML to "<strong>Updated!</strong>"
1 translations
Loading...
Settle Animations animation

Wait for CSS animations to complete

on click add .animate then settle then remove .animate
1 translations
Loading...
Show Element visibility

Show a hidden element

on click show #modal
1 translations
Loading...
Show With Transition visibility

Show element with opacity transition

on click show #modal with *opacity
1 translations
Loading...
Slide Toggle animation

Slide panel open/closed

on click toggle .collapsed on next .panel transition *max-height over 300ms
1 translations
Loading...
Sortable Behavior behavior

Makes child elements reorderable via drag-and-drop. Use: install Sortable(handle: ".drag-handle")

behavior Sortable(handle, dragClass) init if dragClass is undefined set dragClass to "sorting" end end on pointerdown(clientY) from me js(me, handle, event) var target = event.target; var item = target.closest("li"); if (!item || !me.contains(item)) return false; if (handle && !target.closest(handle)) return false; event.preventDefault(); event.stopPropagation(); return true; end if it is false exit end add .{dragClass} to me trigger sortable:start on me repeat until event pointerup from document wait for pointermove(clientY) from document trigger sortable:move on me end remove .{dragClass} from me trigger sortable:end on me end end
1 translations
Loading...
Stagger Animation animation

Staggered entrance animation

on load repeat for item in .item with index add .visible to item wait 100ms end
1 translations
Loading...
Swap Content dom-manipulation

Swap two elements in the DOM

on click swap #a with #b
1 translations
Loading...
Tab Navigation ui-components

Basic tab switching with active state

on click remove .active from .tab add .active to me
1 translations
Loading...
Tab With Content Panel ui-components

Tab that shows associated content panel

on click remove .active from .tab add .active to me hide .tab-panel show the next <div.tab-panel/>
1 translations
Loading...
Tabs Behavior behavior

WAI-ARIA compliant tabs with roving tabindex keyboard navigation. Use: install Tabs(orientation: "vertical")

behavior Tabs(orientation, activeTab, wrap, activeClass) init if orientation is undefined set orientation to "horizontal" end if activeTab is undefined set activeTab to 0 end if wrap is undefined set wrap to true end if activeClass is undefined set activeClass to "active" end js(me, orientation, activeTab, wrap, activeClass) var tabs = Array.from(me.querySelectorAll('[role="tab"]')); var panels = Array.from(me.querySelectorAll('[role="tabpanel"]')); if (tabs.length === 0 || panels.length === 0) return; var tablist = me.querySelector('[role="tablist"]') || tabs[0].parentElement; if (tablist) tablist.setAttribute('aria-orientation', orientation); var count = Math.min(tabs.length, panels.length); var idN = 0; for (var i = 0; i < count; i++) { if (!tabs[i].id) tabs[i].id = 'tab-' + (++idN); if (!panels[i].id) panels[i].id = 'tabpanel-' + idN; tabs[i].setAttribute('aria-controls', panels[i].id); panels[i].setAttribute('aria-labelledby', tabs[i].id); } var cur = Math.max(0, Math.min(activeTab, count - 1)); function activate(idx, prev) { if (idx === prev || idx < 0 || idx >= count) return false; var ev = new CustomEvent('tabs:change', { bubbles: true, cancelable: true, detail: { index: idx, previousIndex: prev } }); me.dispatchEvent(ev); if (ev.defaultPrevented) return false; if (prev >= 0 && prev < count) { tabs[prev].setAttribute('aria-selected', 'false'); tabs[prev].setAttribute('tabindex', '-1'); tabs[prev].classList.remove(activeClass); panels[prev].setAttribute('aria-hidden', 'true'); panels[prev].classList.remove(activeClass); } tabs[idx].setAttribute('aria-selected', 'true'); tabs[idx].setAttribute('tabindex', '0'); tabs[idx].classList.add(activeClass); panels[idx].setAttribute('aria-hidden', 'false'); panels[idx].classList.add(activeClass); cur = idx; me.dispatchEvent(new CustomEvent('tabs:changed', { bubbles: true, detail: { index: idx } })); return true; } for (var j = 0; j < count; j++) { tabs[j].setAttribute('aria-selected', 'false'); tabs[j].setAttribute('tabindex', '-1'); panels[j].setAttribute('aria-hidden', 'true'); panels[j].classList.remove(activeClass); } tabs[cur].setAttribute('aria-selected', 'true'); tabs[cur].setAttribute('tabindex', '0'); tabs[cur].classList.add(activeClass); panels[cur].setAttribute('aria-hidden', 'false'); panels[cur].classList.add(activeClass); for (var k = 0; k < count; k++) { (function(idx) { tabs[idx].addEventListener('click', function() { if (activate(idx, cur)) tabs[idx].focus(); }); })(k); } (tablist || me).addEventListener('keydown', function(e) { var nk = orientation === 'horizontal' ? 'ArrowRight' : 'ArrowDown'; var pk = orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp'; var next = null; if (e.key === nk) { next = cur + 1; if (next >= count) next = wrap ? 0 : null; } else if (e.key === pk) { next = cur - 1; if (next < 0) next = wrap ? count - 1 : null; } else if (e.key === 'Home') next = 0; else if (e.key === 'End') next = count - 1; if (next !== null) { e.preventDefault(); if (activate(next, cur)) tabs[next].focus(); } }); end end end
1 translations
Loading...
Tell Command behaviors

Tell another element to execute a command

on click tell #modal to show
1 translations
Loading...
Toggle ARIA Expanded accessibility

Toggle ARIA expanded state

on click toggle @aria-expanded on me toggle .open on next .panel
1 translations
Loading...
Toggle Class class-manipulation

Toggle a CSS class on the current element when clicked

on click toggle .active
1 translations
Loading...
Toggle Class On Other Element class-manipulation

Toggle a CSS class on another element

on click toggle .open on #menu
1 translations
Loading...
Toggle Visibility visibility

Toggle the hidden attribute on an element

on click toggle @hidden on #panel
1 translations
Loading...
Toggleable Behavior behavior

Toggles a CSS class on click. Use: install Toggleable or install Toggleable(cls: "highlighted", target: "#menu")

behavior Toggleable(cls, target) init if cls is undefined set cls to "active" end if target is undefined set target to me end end on click toggle .{cls} on target js(target, cls) var eventName = target.classList.contains(cls) ? 'toggleable:on' : 'toggleable:off'; target.dispatchEvent(new CustomEvent(eventName, { bubbles: true })); end end end
1 translations
Loading...
Transition Background Color css-styles

Animate background color change

on click transition *background-color to "blue" over 500ms
1 translations
Loading...
Transition Opacity animation

Animate opacity then remove the element

on click transition opacity to 0 over 500ms then remove me
1 translations
Loading...
Transition Transform animation

Animate transform property

on click transition transform to "scale(1.2)" over 300ms
1 translations
Loading...
Trigger Event events

Trigger a custom event when the element loads

on load trigger init
1 translations
Loading...
Two-Way Binding data

Update display as input changes

on input from #firstName set #greeting.innerText to "Hello, " + my value
1 translations
Loading...
Unless Condition control-flow

Execute unless condition is true

on click unless I match .disabled toggle .selected
1 translations
Loading...
Wait For Event timing

Wait for a DOM event to fire

on click wait for transitionend
1 translations
Loading...
Wait Then Execute timing

Wait for a duration before executing a command

on click wait 2s then remove me
1 translations
Loading...
Window Keydown Handler window-events

Handle Ctrl+S globally

on keydown[key=="s"] from window if event.ctrlKey halt call saveDocument() end
1 translations
Loading...