Create a simple text node in the DOM using Sigment's tag functions:
div("Hello, Sigment!")
Example using createSignal
to update a counter on button click:
const [count, setCount] = createSignal(0);
button({ onclick: () => setCount(count() + 1) }, "Clicks: ", count)
Adding a new custom element tag function card()
with addsigment
:
addsigment("card");
card({ class: "item" }, "This is a custom card element")
Render different elements based on a condition:
const loggedIn = true;
div(
loggedIn ? span("Welcome back!") : span("Please login")
)
Rendering a list of items dynamically:
const items = ["Apple", "Banana", "Cherry"];
ul(
...items.map(item => li(item))
)