Skip to content

@arcmantle/lit-jsx / runtime/show-component

runtime/show-component

Functions

Show()

Show<C>(props): unknown

Defined in: runtime/show-component.ts:26

Conditionally renders content based on a truthy value.

Type Parameters

C

C

Parameters

props
children

[(value) => unknown, (value) => unknown] | (value) => unknown

A single render or tuple containing render functions for true and optionally false cases

when

C

The condition value to evaluate for truthiness

Returns

unknown

The rendered JSX element based on the condition's truthiness

Example

tsx
<Show when={user}>
  {(user) => <div>Welcome, {user.name}!</div>}
  {() => <div>Please log in</div>}
</Show>

// Or without fallback
<Show when={isVisible}>
  {() => <div>This content is visible</div>}
</Show>

Released under the Apache-2.0 License.