
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
@asphalt-react/modal
Advanced tools
Modal provides a dialog interface to confirm user actions or to communicate an important message and get a response while maintaining the context of the current view. Modal interrupts a user's workflow by design. Modal blocks the user's access to the on-page content while it's visible. When visible, modal also disables the scroll on the body element and enables it when closed.
Modal is a controlled component and does not manage visibility state on it's own. Modal appears towards the top of the viewport by default but you can place it in center as well.
While effective when used correctly, use Modals sparingly to limit disruption to the user.
import { Modal } from "@asphalt-react/modal"
function App() {
const [open, setOpen] = React.useState(false)
return (
<Modal
open={open}
onClose={() => {
setOpen(false)
}}
>
<span>Are you sure</span>
</Modal>
)
}
Modal exports few additional components to render content. These components help create confirmation dialogs easily.
import { Modal, Title, Description, Footer } from "@asphalt-react/modal"
function App() {
const [open, setOpen] = React.useState(false)
return (
<Modal
open={open}
onClose={() => {
setOpen(false)
}}
>
<Title>Confirm</Title>
<Title>Are you sure</Title>
<Footer>
<Button>Yes</Button>
<Button
onClick={() => {
setOpen(false)
}}
>
No
</Button>
</Footer>
</Modal>
)
}
An immediate response is required from the user:
Use a modal to request information that is preventing the system from continuing a user-initiated process.
Confirm a user decision:
Use a modal to confirm user decisions. Clearly describe the action being confirmed and explain any potential consequences that it may cause. Both the title and the primary button should reflect the action that will occur. If the action is destructive or irreversible then use a danger modal.
Modals prevent access to the main page:
Don’t use if additional information outside the modal needs to be consulted. While a modal is opened a user cannot interact with the main page and is restricted to only the information inside the modal for making decisions. Modal tasks should be easy to complete with the limited information presented inside the modal itself. If a user needs access to additional information then consider using a full page instead.
Avoid nesting modals:
One modal should never trigger another modal. When a modal's task is dependent on another modal then perform the first task outside of a modal.
Avoid full page modals:
Avoid using modals to display complex forms or large amounts of information. If a modal needs more space than the component allows then the content should be displayed on a page of its own and not inside a modal. A modal is not an alternative to page.
Adds aria-modal attribute to let assistive technologies handle it as a dialog role. By default the first focusable element receives focus when modal opens. Modal passes aria-* attributes to its topmost element.
For better screen reader support, add an id to the description node and apply it to aria-describedby.
Modal accepts data-* attributes and forwards them to its top level element.
React Node for modal content.
| type | required | default |
|---|---|---|
| node | false | null |
Controls the visibility of the modal.
| type | required | default |
|---|---|---|
| bool | false | false |
Adds padding inside modal.
| type | required | default |
|---|---|---|
| bool | false | true |
Closes modal on ESC keypress.
| type | required | default |
|---|---|---|
| bool | false | true |
Places the modal in the center of the viewport.
| type | required | default |
|---|---|---|
| bool | false | false |
Function to call when modal closes.
| type | required | default |
|---|---|---|
| func | false | null |
Prevents the content behind the Modal from scrolling when the Modal is visible.
| type | required | default |
|---|---|---|
| bool | false | true |
Add a cross button to the top right of the modal.
| type | required | default |
|---|---|---|
| bool | false | false |
Title renders a heading for the Modal's content.
Title of the modal.
| type | required | default |
|---|---|---|
| node | false | null |
Adds a margin to separate it from its sibling elements.
| type | required | default |
|---|---|---|
| bool | false | true |
Description renders the content for the Dialog.
Node for content
| type | required | default |
|---|---|---|
| node | false | null |
Adds a margin to separate it from its sibling elements.
| type | required | default |
|---|---|---|
| bool | false | true |
Use Footer to add interactive elements in Modal to accept user actions.
Node for content.
| type | required | default |
|---|---|---|
| node | false | null |
Places the content at center.
| type | required | default |
|---|---|---|
| bool | false | false |
Places the content at the end.
| type | required | default |
|---|---|---|
| bool | false | false |
Modal uses the "dialog" element which is well supported on all major browsers. This is still a fairly new API which the browsers vendors added recently. If you have users that use older browsers which lack support for the "dialog" element, use the ModalLegacy component to wrap the Modal component.
import { Modal, ModalLegacy } from "@asphalt-react/modal"
export const App = () => {
const modalRef = React.useRef(null)
return (
<ModalLegacy modalRef={modalRef}>
<Modal open={true} ref={modalRef}>Lorem ipsum</Modal>
</ModalLegacy>
)
}
Modal to render in older browsers.
| type | required | default |
|---|---|---|
| node | false | N/A |
React ref of the Modal.
| type | required | default |
|---|---|---|
| union | false | N/A |
FAQs
Modal
The npm package @asphalt-react/modal receives a total of 13 weekly downloads. As such, @asphalt-react/modal popularity was classified as not popular.
We found that @asphalt-react/modal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.