Show

Renders its content when a condition is true, and a fallback when it is false.

Usage

Code
import { Show } from '@leverui/components';
Code
<Show when={...} fallback={...}>
  <div>Content</div>
</Show>

Examples

Fallback

Use the fallback prop to render a fallback component when the array is empty or undefined.

Not there yet. Keep clicking...

Render Prop

Use the children render prop to narrow the type of the when value and remove undefined | null

Value: 10

Props

PropDefaultTypeDescription
when—T | null | undefinedRender children when truthy.
fallback—JSX.ElementContent to render when when is falsy.
children—JSX.Element | ((value: Accessor<NonNullable<T>>) => JSX.Element)Content, or a function given an accessor. Value is never null or undefined.

Show adds no wrapper element, so it has no as or asChild. When the value changes but stays truthy, the accessor returns the new value and the content is not rebuilt. Use the right HTML elements in each branch.

No Lever UI styles and no style tag. Style the content yourself.