Smart Element Toggle

Demonstrating smart detection and toggle for <dialog>, <details>, <summary>, and <select> elements.

πŸ“± Dialog Elements Dialog

Dialog Toggle (Non-Modal & Modal)

<button _="on click toggle #infoDialog">Non-Modal</button> <button _="on click toggle #alertDialog modal">Modal</button>

ℹ️ Non-Modal Dialog

This dialog opened with show().

You can still interact with the page!

⚠️ Modal Dialog

This dialog opened with showModal().

Page interaction is blocked!

πŸ“‚ Details Elements Details

Accordion / FAQ with Toggle

<button _="on click toggle #faq1">Toggle FAQ 1</button> <details id="faq1"> <summary>What is LokaScript?</summary> <p>Content here...</p> </details>
What is LokaScript?

LokaScript is a complete hyperscript ecosystem with smart element detection, making web interactions natural and concise.

How does smart toggle work?

Smart toggle automatically detects interactive elements like dialog, details, and select, and toggles their state appropriately without needing explicit method calls.

Is it compatible with _hyperscript?

Yes! LokaScript maintains compatibility with official _hyperscript syntax while adding enhanced features and smart detection.

Summary Element Toggle (Automatic Parent Detection)

<!-- Toggle by targeting summary element directly --> <button _="on click toggle #summary1">Toggle via Summary</button> <details> <summary id="summary1">Click me or the button</summary> <p>Content expands when you toggle the summary!</p> </details>

When you toggle a <summary> element, it automatically finds and toggles the parent <details>.

✨ Advanced Summary Toggle

This demonstrates that you can target the summary element directly!

The toggle command automatically detects the parent details and toggles it.

  • βœ… toggle #summaryElement works
  • βœ… toggle #detailsElement works
  • βœ… Both achieve the same result

🎚️ Select Elements Select

Programmatic Dropdown Control

<button _="on click toggle #countrySelect">Toggle Dropdown</button> <select id="countrySelect"> <option>USA</option> <option>Canada</option> </select>

🎨 Combined Smart Toggle

Interactive Settings Panel

βš™οΈ Settings

General Settings

Advanced Settings

Enable experimental features and developer options.

About

LokaScript v1.0.0 - Smart Element Toggle Demo

πŸ§ͺ Experimental Features

Beta Feature 1

This is a beta feature currently in testing.

Beta Feature 2

Another experimental capability.

πŸ“Š Summary Reference

Smart Element Toggle Syntax

Element Syntax Behavior
<dialog> toggle #myDialog Non-modal (show/close)
<dialog> toggle #myDialog as modal Modal (showModal/close)
<details> toggle #myDetails Expand/collapse
<summary> toggle #mySummary Toggle parent details
<select> toggle #mySelect Focus/blur dropdown
Any element toggle .className Toggle CSS class
Any element toggle @attribute Toggle HTML attribute

Key Features

Compatibility Matrix

Feature Dialog Details Select
Smart Toggle βœ… Yes βœ… Yes βœ… Yes
Class Toggle βœ… Yes βœ… Yes βœ… Yes
Attribute Toggle βœ… Yes βœ… Yes βœ… Yes
Event Dispatch βœ… Yes βœ… Yes βœ… Yes
Multiple Elements βœ… Yes βœ… Yes βœ… Yes