Modal Component
Modal Examples with useModal Hook
Simple Modal
Responsive Fullscreen (Breakpoint)
Toggle Modal (with State Tracking)
Closed
Alert Modals (Single Button)
Confirmation Modals (Two Buttons)
Fullscreen Modal
Responsive & Placement
Custom Width
Behavior Options
Custom Footer
Form in Modal
useModal Hook Usage
const { modalRef, open, close, toggle, isOpen } = useModal() ;// With callbacksconst { modalRef, open } = useModal({ onOpen: () => console.log('Opened'), onClose: () => console.log('Closed'),}) ;<Button onClick={ open }>Open</Button><Modal ref={ modalRef }>Content</Modal>Stacked Modals (Nesting)
You can open multiple modals on top of each other. The browser handles the stacking order.
CRUD Hooks Demo
useAddModal, useEditModal, useRemoveModal
Total Users
4
Developers
2
Designers
1
| Name | Phone | Role | Actions | |
|---|---|---|---|---|
AJ Alice Johnson | alice@example.com | 555-0101 | Developer | |
BS Bob Smith | bob@example.com | 555-0102 | Designer | |
CB Charlie Brown | charlie@example.com | 555-0103 | Manager | |
DP Diana Prince | diana@example.com | 555-0104 | Developer |
useAddModal State
valid: ✗
useEditModal State
hasChanges: ✗
valid: ✗
useRemoveModal State
ready: ✓
InputModal - Open on Focus Demo
Click on the input or use the button to open the modal
With openOnFocus
Click the input field or the button to open
#3b82f6
Without openOnFocus
Only the button opens the modal
Try clicking the input field - nothing happens. You must use the "Choose" button.
When to use openOnFocus?
✅ Good for:
- Date pickers
- Time pickers
- Color pickers
- Single-click selections
- Read-only inputs
❌ Avoid for:
- Complex forms
- Multi-step selections
- When typing is needed
- File uploads
- Editable inputs
// ✅ Pattern correct avec état temporaireconst [value, setValue] = useState(initial) ;const [tempValue, setTempValue] = useState(initial) ;<InputModal value={value} // Affiche finale onModalOpen={() => setTempValue(value)} onAgree={() => setValue(tempValue)}> <input value={tempValue} onChange={setTempValue} /></InputModal>Additional Options
Hide Action Button
Use showActionButton={false} to hide the button
Custom onFocus Handler
Combine with your own focus handler