| name | portal-dropdown-components |
| description | Build React Portal-based dropdown, modal, and overlay components. Use when creating dropdown menus, select components, modals, tooltips, or any UI that needs to escape overflow containers. Includes positioning, scroll handling, keyboard navigation, and accessibility patterns. |
Portal Dropdown Components
React Portal ๊ธฐ๋ฐ ๋๋กญ๋ค์ด, ๋ชจ๋ฌ, ์ค๋ฒ๋ ์ด ์ปดํฌ๋ํธ ๊ฐ๋ฐ ์คํฌ์
๋๋ค.
Quick Reference
Portal ๊ธฐ๋ณธ ํจํด
import { createPortal } from 'react-dom';
function Dropdown({ isOpen, position, children }) {
if (!isOpen) return null;
return createPortal(
<div style={{ position: 'fixed', ...position }}>
{children}
</div>,
document.body
);
}
ํต์ฌ ๊ธฐ๋ฅ
- โ
position: fixed + ํ๋ฉด ์ขํ ๊ณ์ฐ
- โ
์ธ๋ถ ํด๋ฆญ ๊ฐ์ง (Click Outside)
- โ
ESC ํค ๋ซ๊ธฐ
- โ
์คํฌ๋กค ์ ์์น ์
๋ฐ์ดํธ
- โ
ํฌ์ปค์ค ํธ๋ฉ (๋ชจ๋ฌ)
Contents
When to Use
- ๋๋กญ๋ค์ด ๋ฉ๋ด๊ฐ
overflow: hidden ์ปจํ
์ด๋์ ์๋ฆฌ๋ ๊ฒฝ์ฐ
- z-index ์คํํน ์ปจํ
์คํธ ๋ฌธ์ ํด๊ฒฐ ์
- ์คํฌ๋กค ๊ฐ๋ฅํ ์ปจํ
์ด๋ ๋ด ๋๋กญ๋ค์ด ๊ตฌํ ์
- ์ ๊ทผ์ฑ ์๊ตฌ์ฌํญ์ ์ถฉ์กฑํ๋ UI ์ปดํฌ๋ํธ ๊ฐ๋ฐ ์