Show
Renders its content when a condition is true, and a fallback when it is false.
Usage
import { Show } from '@leverui/components';
<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
| Prop | Default | Type | Description |
|---|---|---|---|
when | — | T | null | undefined | Render children when truthy. |
fallback | — | JSX.Element | Content 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.