Sigment Examples

Hello World

Create a simple text node in the DOM using Sigment's tag functions:

div("Hello, Sigment!")

Reactive Counter

Example using createSignal to update a counter on button click:

const [count, setCount] = createSignal(0);

button({ onclick: () => setCount(count() + 1) }, "Clicks: ", count)

Custom Tag

Adding a new custom element tag function card() with addsigment:

addsigment("card");

card({ class: "item" }, "This is a custom card element")

Conditional Rendering

Render different elements based on a condition:

const loggedIn = true;

div(
  loggedIn ? span("Welcome back!") : span("Please login")
)

Looping with map()

Rendering a list of items dynamically:

const items = ["Apple", "Banana", "Cherry"];

ul(
  ...items.map(item => li(item))
)