Live playground
Try authored Litsx immediately
Edit JSX, inspect the emitted output, and preview the generated web component without leaving the home page.
import { useState } from "litsx";
type ComposerProps = {
name: string;
};
export function Composer({ name = "world" }: ComposerProps) {
const [count, setCount] = useState(0);
^styles(`
:host {
display: block;
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
color: #e5e7eb;
}
button {
font: inherit;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
.card {
width: min(100%, 24rem);
padding: 1rem;
border-radius: 1rem;
background:
radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 40%),
linear-gradient(160deg, #141d2e, #0f172a);
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
}
.title {
margin: 0;
font-size: 1.5rem;
font-weight: 700;
line-height: 1.1;
}
.accent {
color: #ff9f84;
}
.row {
margin-top: 1rem;
display: flex;
align-items: center;
}
.button {
appearance: none;
border: 0;
border-radius: 999px;
padding: 0.55rem 0.9rem;
background: #ff8666;
color: white;
cursor: pointer;
font-weight: 600;
}
.preview {
margin-top: 1rem;
padding: 0.85rem 0.95rem;
border-radius: 0.95rem;
background: rgba(148, 163, 184, 0.12);
}
.body {
margin: 0;
line-height: 1.45;
color: rgba(226, 232, 240, 0.9);
}
`);
return (
<section class="card">
<h2 class="title">
Hello, <span class="accent">{name}</span>.
</h2>
<div class="row">
<button class="button" @click={() => setCount((value) => value + 1)}>
Click me
</button>
</div>
<div class="preview">
<p class="body">
You clicked <strong>{count}</strong> time{count === 1 ? "" : "s"}.
</p>
</div>
</section>
);
}