Skip to main content
The Show component provides a clean, declarative way to conditionally render content in React, with built-in support for fallback UI and multiple rendering patterns.

When to Use

  • Conditionally render components based on a value
  • Display different UI for truthy vs falsy states
  • Show loading or empty states elegantly
  • Avoid ternary operator chains in JSX
  • Pass resolved values to child render functions

Basic Usage

Component API

Show.Root

The root component that manages conditional rendering.
TWhen | false | null | undefined
Condition to evaluate. If truthy, renders children; if falsy, renders fallback. Not used with control="content"
React.ReactNode | ((value: TWhen) => React.ReactNode)
required
Content to render when condition is true. Can be a render function receiving the resolved value
React.ReactNode
Content to render when condition is false
'root' | 'content'
default:"root"
  • 'root': Use when prop to control rendering
  • 'content': Use Show.Content children with individual when props

Show.Content

Defines conditional content within a content-controlled Show.
TWhen | false | null | undefined
required
Condition for this content block
React.ReactNode | ((value: TWhen) => React.ReactNode)
required
Content to render. Can be a render function receiving the resolved value

Show.Fallback / Show.Otherwise

Defines fallback content when no conditions match.
React.ReactNode
required
Fallback content to display
Show.Otherwise is an alias for Show.Fallback.

Examples

Authentication State

Loading States

Permission-Based Rendering

Nested Conditions

Form Validation Messages

Multiple Fallback Options

Comparison to Native Patterns

Ternary Operator

&& Operator

With Show Component

Common Use Cases

API Response Handling

Feature Toggles

Empty States

When using render functions with when, the resolved truthy value is automatically passed to the function, providing type-safe access without null checks.