If
Declarative boolean conditional rendering with lazy function execution.
1.1 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-components-ifUsage
Code
import { If } from '@/components/if'
import { If } from '@/components/if'```
```tsx
<If condition={isLoggedIn} fallback={<p>Logged Out</p>}>
<p>Welcome back!</p>
</If>API Reference
Parameters / Props
| Prop | Type | Default | Description |
|---|---|---|---|
condition | boolean|(() => boolean) | required | Boolean condition. |
fallback | ReactNode | null | Fallback branch. |
Return Value
| Return Type | Description |
|---|---|
ReactNode | Rendered output. |