Skip to content

Instantly share code, notes, and snippets.

@JLarky
Created July 22, 2025 16:15
Show Gist options
  • Save JLarky/472efbe7d6d3a366f0fecb7c582c03af to your computer and use it in GitHub Desktop.
Save JLarky/472efbe7d6d3a366f0fecb7c582c03af to your computer and use it in GitHub Desktop.
lift-html solid counter
import { liftHtml } from '@lift-html/core';
import html from "solid-js/html";
import { createSignal } from "solid-js";
import { render } from "solid-js/web";
const css = /*css*/ `
* { font-size: 200%; }
span {
width: 4rem;
display: inline-block;
text-align: center;
}
button {
width: 4rem; height: 4rem;
border: none;
border-radius: 10px;
background-color: seagreen;
color: white;
outline: none;
cursor: pointer;
}
`
liftHtml('my-counter', {
init() {
const [count, setCount] = createSignal(0);
const App = () => html`
<style>${css}</style>
<button onClick=${() => setCount(count() - 1)}>-</button>
<span>${count}</span>
<button onClick=${() => setCount(count() + 1)}>+</button>
`
render(App, this.shadowRoot || this.attachShadow( {mode: 'open' }));
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment