permalink | title |
---|---|
pat/toggle/ |
Toggle |
A pattern to toggle classes on HTML elements.
This mockup pattern will probably replaced by patternslib/toggle. Some features are already broken like "Toggle an element by hover event". We decided to not migrate all examples and no tests.
Option | Type | Default | Description |
---|---|---|---|
target | string | null | selector of the target elements to toggle ('undefied') |
targetScope | null | selector of a target scope element in anchestors ('global') | |
attribute | string | null | element attribute which will be toggeled ('class') |
event | string | null | event which will trigger toggling ('click') |
This button goes bigger/smaller!
<button type="button" class="btn btn-primary pat-toggle" data-pat-toggle="value:btn-lg;">
This button goes bigger/smaller!
</button>
This button is toggling the background of a element.
Hello World
Hello World
<div class="wrapper">
<button
type="button"
class="btn btn-primary pat-toggle mb-2"
data-pat-toggle="value:badge-success;target:.targetElement"
>
This button is toggling the background of a element.</button
><br />
<span class="targetElement badge bg-secondary">Hello World</span>
</div>
toggle
Hello World
Hello World
toggle
Hello World
Hello World
<div class="wrapper">
<div class="myScope">
<button
type="button"
class="btn btn-primary pat-toggle mb-2"
data-pat-toggle="value:bg-success;target:.targetElement;targetScope:.myScope;"
>
toggle</button
><br />
<span class="targetElement badge bg-secondary mb-4">Hello World</span>
</div>
<div class="myScope">
<button
type="button"
class="btn btn-primary pat-toggle mb-2"
data-pat-toggle="value:bg-success;target:.targetElement;targetScope:.myScope;"
>
toggle</button
><br />
<span class="targetElement badge bg-secondary">Hello World</span>
</div>
</div>
toggle
Hello World Hello again
Hello World Hello again
toggle
Hello World
Hello World
<div class="wrapper">
<div class="myScope">
<button
type="button"
class="btn btn-primary pat-toggle mb-2"
data-pat-toggle="value:bg-success;target:.targetElement;targetScope:.myScope;"
>
toggle</button
><br />
<span class="targetElement badge bg-secondary">Hello World</span>
<span class="targetElement badge bg-secondary mb-4">Hello again</span>
</div>
<div class="myScope">
<button
type="button"
class="btn btn-primary pat-toggle mb-2"
data-pat-toggle="value:bg-success;target:.targetElement;targetScope:.myScope;"
>
toggle</button
><br />
<span class="targetElement badge bg-secondary">Hello World</span>
</div>
</div>