Modal

Modal dialog component

Click the "Show modal" button to trigger the modal.




1import Modal from "@tempoplatform/tpds/components/modal"
2import { Button } from '@tempoplatform/tpds/elements/buttons'
3
4
5export default function Page() {
6  const [error, setError] = React.useState(false)
7
8  const errorModal = (
9    <Modal
10      showOpen={error}
11      title="The request failed"
12      description="The server rejected the request"
13      content={
14        <div className="flex flex-col gap-y-4">
15          <PSmall className="leading-normal">
16            An error ocurred while submitting the form. Please review your data or contact support.
17          </PSmall>
18        </div>
19      }
20      options={[
21        {
22          label: 'Return to form',
23          variant: 'info',
24          callBack: () => {
25            setError(false)
26          },
27        },
28      ]}
29    />
30  )
31  
32  return (
33    <>
34      <Button variant="info" onClick={() => setShowModal(true)}>
35        Show modal
36      </Button>
37      <br />
38      {errorModal}
39    </>
40  )
41}


Prop Name

Type

Default

Required

Description

showOpen

Boolean

false

yes

The title of the modal

title

String

' '

yes

The title of the modal

description

String

no

Subtitle to display under the title

content

JSX

null

no

Custom content to display inside the modal.

options

Array

Close button

no

The buttons to render at the bottom of the modal. If not passed, a close button will be rendered.

clickElement

JSX Element

null

no

The element to click to open the modal. If not passed, the modal will open if 'showOpen' is true.

maxWidth

String | Number

500px

no

The maximum width of the modal. Can be a string or a number.

overlayProps

Object

null

no

Any props to pass to the overlay element.

titleProps

Object

null

no

Any props to pass to the title element.

descriptionProps

Object

null

no

Any props to pass to the description element.

dialogOnClose

Function

null

no

A function to call when the modal is closed.