Skip to content

Conditionals

Three properties control whether a widget renders:

PropertyShape
include{ in: ['stateName'] } — render only when all named states are active. Or { when: '<expr>' } — render only when the expression is truthy.
excludeSame shape as include, but inverted — render only when the named states are not active.
import { gui } from '@golemui/gui-shared';
// Render only when the 'hasDiscount' state is active
gui.inputs.textInput('discountCode', {
label: 'Discount code',
include: { in: ['hasDiscount'] },
});
// Render only when an inline expression is truthy
gui.inputs.numberInput('pets', {
label: 'Number of pets',
include: { when: '$form.includePets === true' },
});
// Hide a button when 'submitting' is active
gui.actions.button({
label: 'Submit',
exclude: { in: ['submitting'] },
});
  • include with in — the condition has a name, used in multiple places.
  • include with when — one-off, expressed inline.
  • exclude — sometimes a “hide-when” rule reads more naturally than the corresponding “show-when”.