REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.07 KB
Close
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/frontend/hooks/use-modal.doc.md
Text
Base64
`useModal` hook is used to utilize @adminjs-design-system `Modal` molecule embedded in AdminJS components structure. ### Where you might want to use it? The hook was designed to be used in three cases * display alert information (non blocking) * display confirm window * display any content in modal ## Examples Let's create simple React component with button to fire modal example. We will change `openModal` props to demonstrate modal usage ```javascript import { Box, Button, Input, Label, Text, TextArea } from '@adminjs/design-system' import { useModal } from 'adminjs' import React from 'react' const ModalPage = () => { const { openModal, closeModal } = useModal() const modalConfig = { // here we put modal config } return ( <Button onClick={() => { openModal(modalConfig) }} > Open modal </Button> ) } ``` ### Alert To display alert modal we feed following object into `openModal` function ```javascript const modalConfig = { modalProps: { title: 'somethingHappened', variant: 'info' }, type: 'alert', } ``` ### Confirm Confirm modal require function `confirmAction` which will be fired after confirm, so example config can look like this ```javascript const modalConfig = { modalProps: { title: 'areYouSureToDoThis', variant: 'danger' }, type: 'confirm', confirmAction: () => { console.log('Confirmed !!!') }, } ``` ### Form We can display any content in our modal. For demo purposes we create simple form component ```javascript const feedbackForm = () => { return ( <Box> <Text> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </Text> <Box mt="lg"> <Label htmlFor="name">Name</Label> <Input id="name" width={1} /> </Box> <Box mt="lg"> <Label htmlFor="comment">Feedback</Label> <TextArea id="comment" width={1} /> </Box> </Box> ) } ``` Then add few lines above our modal config ```javascript const feedbackFormComponent = feedbackForm() const sendFeedback = () => { console.log('Feedback sent ...') closeModal() } const modalConfig = { modalProps: { variant: 'success', icon: 'Grid', label: 'feedback', title: 'pleaseSendUsFeedback', buttons: [{ label: 'cancel' }, { label: 'sendFeedback', variant: 'success', onClick: sendFeedback }], children: feedbackFormComponent, width: 0.4, }, } ``` Modal props are described in [adminjs-design-system source code](https://github.com/SoftwareBrothers/adminjs-design-system/tree/master/src/molecules/modal)
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 6 × Files: 10
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
use-action
DIR
-
drwxr-xr-x
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-local-storage
DIR
-
drwxr-xr-x
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-record
DIR
-
drwxr-xr-x
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-records
DIR
-
drwxr-xr-x
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-resource
DIR
-
drwxr-xr-x
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-selected-records
DIR
-
drwxr-xr-x
2026-02-28 00:31:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.js
563 B
lrw-r--r--
2026-02-28 00:31:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-current-admin.js
1.19 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-filter-drawer.js
900 B
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-history-listen.js
1.02 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-modal.doc.md
3.07 KB
lrw-r--r--
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-modal.js
2.19 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-navigation-resources.js
2.16 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-notice.js
709 B
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-query-params.js
2.20 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
use-translation.js
1.34 KB
lrw-r--r--
2026-02-28 00:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).