@zeix/ui-element
Version:
UIElement - a HTML-first library for reactive Web Components
181 lines (169 loc) • 5.84 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>toggleClass – UIElement Docs</title>
<meta name="description" content="" />
<link rel="stylesheet" href="../../assets/main.css" />
<script type="module" src="../../assets/main.js"></script>
</head>
<body class="api">
<context-router>
<header class="content-grid">
<h1 class="content">
UIElement Docs <small>Version 0.13.3</small>
</h1>
<section-menu>
<nav>
<h2 class="visually-hidden">Main Menu</h2>
<ol>
<li>
<a href="../../index.html">
<span class="icon">📖</span>
<strong>Introduction</strong>
<small>Overview and key benefits of UIElement</small>
</a>
</li>
<li>
<a href="../../getting-started.html">
<span class="icon">🚀</span>
<strong>Getting Started</strong>
<small>Installation, setup, and first steps</small>
</a>
</li>
<li>
<a href="../../components.html">
<span class="icon">🏗️</span>
<strong>Components</strong>
<small>Anatomy, lifecycle, signals, effects</small>
</a>
</li>
<li>
<a href="../../styling.html">
<span class="icon">🎨</span>
<strong>Styling</strong>
<small>Scoped styles, CSS custom properties</small>
</a>
</li>
<li>
<a href="../../data-flow.html">
<span class="icon">🔄</span>
<strong>Data Flow</strong>
<small>Passing state, events, context</small>
</a>
</li>
<li>
<a href="../../examples.html">
<span class="icon">🍽️</span>
<strong>Examples</strong>
<small>Common use cases and demos</small>
</a>
</li>
<li>
<a href="../../blog.html">
<span class="icon">📜</span>
<strong>Blog</strong>
<small>Latest articles and updates</small>
</a>
</li>
<li>
<a href="../../api.html">
<span class="icon">📚</span>
<strong>API Reference</strong>
<small>Functions, types, and constants</small>
</a>
</li>
<li>
<a href="../../about.html">
<span class="icon">🤝</span>
<strong>About</strong>
<small>License, versioning, getting involved</small>
</a>
</li>
</ol>
</nav>
</section-menu>
<card-callout class="content danger" hidden>
<p class="error" role="alert" aria-live="polite"></p>
</card-callout>
</header>
<main class="content-grid"><section class="api-content">
<h1 id="function-toggleclass">
<a name="function-toggleclass" class="anchor" href="#function-toggleclass">
<span class="permalink">🔗</span>
</a>
Function: toggleClass()
</h1>
<blockquote>
<p><strong>toggleClass</strong><<code>P</code>, <code>E</code>>(<code>token</code>, <code>reactive</code>): <a href="../type-aliases/Effect.html"><code>Effect</code></a><<code>P</code>, <code>E</code>></p>
</blockquote>
<p>Defined in: <a href="https://github.com/zeixcom/ui-element/blob/f80be4b02c5d1c80817271ddf0fad982e43ad03e/src/lib/effects.ts#L550">src/lib/effects.ts:550</a></p>
<p>Effect for toggling a CSS class token on an element.<br>When the reactive value is true, the class is added; when false, it's removed.</p>
<h2 id="type-parameters">
<a name="type-parameters" class="anchor" href="#type-parameters">
<span class="permalink">🔗</span>
</a>
Type Parameters
</h2>
<h3 id="p">
<a name="p" class="anchor" href="#p">
<span class="permalink">🔗</span>
</a>
P
</h3>
<p><code>P</code> <em>extends</em> <a href="../type-aliases/ComponentProps.html"><code>ComponentProps</code></a></p>
<h3 id="e">
<a name="e" class="anchor" href="#e">
<span class="permalink">🔗</span>
</a>
E
</h3>
<p><code>E</code> <em>extends</em> <code>Element</code> = <code>HTMLElement</code></p>
<h2 id="parameters">
<a name="parameters" class="anchor" href="#parameters">
<span class="permalink">🔗</span>
</a>
Parameters
</h2>
<h3 id="token">
<a name="token" class="anchor" href="#token">
<span class="permalink">🔗</span>
</a>
token
</h3>
<p><code>string</code></p>
<p>CSS class token to toggle</p>
<h3 id="reactive">
<a name="reactive" class="anchor" href="#reactive">
<span class="permalink">🔗</span>
</a>
reactive
</h3>
<p><a href="../type-aliases/Reactive.html"><code>Reactive</code></a><<code>boolean</code>, <code>P</code>, <code>E</code>> = <code>token</code></p>
<p>Reactive value bound to the class presence (defaults to class name)</p>
<h2 id="returns">
<a name="returns" class="anchor" href="#returns">
<span class="permalink">🔗</span>
</a>
Returns
</h2>
<p><a href="../type-aliases/Effect.html"><code>Effect</code></a><<code>P</code>, <code>E</code>></p>
<p>Effect function that toggles the class on the element</p>
<h2 id="since">
<a name="since" class="anchor" href="#since">
<span class="permalink">🔗</span>
</a>
Since
</h2>
<p>0.8.0</p>
</section></main>
<footer class="content-grid">
<div class="content">
<h2 class="visually-hidden">Footer</h2>
<p>© 2024 – 2025 Zeix AG</p>
</div>
</footer>
</context-router>
</body>
</html>