Helpers·loomora/ConditionalWrapper
⚙Related configs↗

ConditionalWrapper

A helper for optional element composition based on a child condition and fallback wrapper configuration.

Interactive live playground

Tweak props, change states, and see the live component respond in real time.

Live

How to call

Import directly from the Loomora package root. For projects without Tailwind CSS, ensure loomora/dist/index.css is imported once in your root layout.

import { ConditionalWrapper } from 'loomora'

<ConditionalWrapper
  childrenCondition={Boolean(link)}
  fallback={{ as: 'div', attributes: { className: 'rounded-xl p-4' } }}
>
  Content
</ConditionalWrapper>

API reference

Important public props and how they affect rendering.

4 props
PropTypeDefaultDescription
childrenConditionbooleanfalseControls whether the primary wrapper is used.
childrenReactNode—Content passed through the selected wrapper.
wrapperwrapper configuration—Primary element/component wrapper props.
fallbackwrapper configuration—Optional wrapper configuration when condition is false.