Optional
key: ((val) => any)https://github.com/nombrekeff/cardboard-js/wiki/Logic
Static list
const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
div(
each(colors, (color) =>
button(color).addStyle('color', color)
)
);
Dynamic list
const colors = state(['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']);
const selectedColor = state('red');
div(
each(colors, (color) =>
button(color)
.addStyle('color', color)
.stylesIf(equalTo(selectedColor, color), { fontWeight: 'bold' });
)
);
Generated using TypeDoc
Render a CTag for each item in the provided list.
each
can work with a goold old array, or with a IConsumable. If you provide aConsumable
, the list will update whenever theConsumable
changes.