This counter uses FlowUI. Use the buttons to change the count.
@notswssr/flowui directly from npm. Use a bundler such as
Vite to load the npm package in your app.
import {
VStack, HStack, Text, Button,
State, mount, Color, Font
} from '@notswssr/flowui';
function Counter() {
const count = new State(0);
return VStack(
Text("Counter")
.font(Font.headline())
.padding("bottom", 20),
HStack(
Button("-")
.onTap(() => count.value--)
.padding(10),
Text("0")
.bind(count, (value, component) => {
component.text(value.toString());
})
.padding("horizontal", 20)
.font(Font.title()),
Button("+")
.onTap(() => count.value++)
.padding(10)
)
.padding("bottom", 20),
Text("Current count: 0")
.bind(count, (value, component) => {
component.text(`Current count: ${value}`);
})
)
.padding(20)
.backgroundColor(Color.gray.opacity(0.1))
.cornerRadius(10);
}
mount(Counter(), "#app");
This counter example demonstrates these key FlowUI concepts:
State to create
reactive variables
VStack, HStack, Text, and
Button components
onTap for button
click events
bind to update UI when
state changes