Portal
A component that renders its children in a different DOM node.
Installation
npm install @cleartrip/ct-design-portal
# or
pnpm add @cleartrip/ct-design-portal
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Portal } from '@cleartrip/ct-design-portal';
function Example() {
return (
<Portal>
{/* Basic usage */}
</Portal>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | ReactNode | — | ✅ Yes | The content to be rendered inside the portal. |
id | string | — | ✅ Yes | Unique identifier for the portal instance. On native, this is used by the |
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Portal } from 'yagami/core/components';
+ import { Portal } from '@cleartrip/ct-design-portal';