5.0.14 • Published 24 days ago

@leafygreen-ui/confirmation-modal v5.0.14

Weekly downloads
19
License
Apache-2.0
Repository
github
Last release
24 days ago

Confirmation Modal

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/confirmation-modal

NPM

npm install @leafygreen-ui/confirmation-modal

Example

import ConfirmationModal from '@leafygreen-ui/confirmation-modal';

function ExampleComponent() {
  const [open, setOpen] = useState(false);

  return (
    <>
      <button onClick={() => setOpen(!open)}>Open Modal</button>
      <ConfirmationModal
        open={open}
        onConfirm={() => setOpen(false)}
        onCancel={() => setOpen(false)}
        title="Confirm Title Here"
        buttonText="Confirm"
        requiredInputText="confirm"
      >
        This is some description text, and it is extra long so it fills up this
        modal. Another thing about the modals here. This is some description
        text, and it is extra long so it fills up this modal. Another thing
        about the modals here.
      </ConfirmationModal>
    </>
  );
}

Output HTML

<button>Open Modal</button>
<div aria-modal="true" role="dialog" tabindex="-1" class="leafygreen-ui-iiijf">
  <button
    tabindex="0"
    aria-disabled="false"
    aria-label="Close modal"
    class="leafygreen-ui-zndd6x"
  >
    <div class="leafygreen-ui-xhlipt">
      <svg
        class="leafygreen-ui-19fdo3o"
        height="20"
        width="20"
        viewBox="0 0 16 16"
        role="img"
      >
        <g
          id="X-Copy"
          stroke="none"
          stroke-width="1"
          fill="none"
          fill-rule="evenodd"
        >
          <path
            d="M9,7 L13.5,7 L13.5,9 L9,9 L9,13.5 L7,13.5 L7,9 L2.5,9 L2.5,7 L7,7 L7,2.5 L9,2.5 L9,7 Z"
            id="Combined-Shape-Copy"
            fill="currentColor"
            transform="translate(8.000000, 8.000000) rotate(45.000000) translate(-8.000000, -8.000000) "
          ></path>
        </g>
      </svg>
    </div>
  </button>
  <div class="leafygreen-ui-19fzdo8">
    <div class="leafygreen-ui-1dhn1u9">Confirm Title Here</div>
    This is some description text, and it is extra long so it fills up this
    modal. Another thing about the modals here. This is some description text,
    and it is extra long so it fills up this modal. Another thing about the
    modals here.
    <div class="leafygreen-ui-1dzzoy1">
      <label for="text-input-23" class="leafygreen-ui-1uh6n1l"
        >Type "confirm" to confirm your action</label
      >
      <div class="leafygreen-ui-lzja97">
        <input
          data-leafygreen-ui="input-selector"
          type="text"
          class="leafygreen-ui-om9pvn"
          required=""
          id="text-input-23"
          value=""
        />
        <div
          data-leafygreen-ui="icon-selector"
          class="leafygreen-ui-m329s1"
        ></div>
        <div class="leafygreen-ui-1andb55"></div>
      </div>
    </div>
  </div>
  <div class="leafygreen-ui-1ewqwyu undefined">
    <button
      type="button"
      class="leafygreen-ui-1fv4ilm"
      aria-disabled="true"
      disabled=""
    >
      <span class="leafygreen-ui-1cpk24m">Confirm</span></button
    ><button type="button" class="leafygreen-ui-moke9e" aria-disabled="false">
      <span class="leafygreen-ui-1cpk24m">Cancel</span>
    </button>
  </div>
</div>

Properties

PropTypeDescriptionDefault
openbooleanDetermines open state of Modal componentfalse
onConfirmfunctionCallback that fires when the action is confirmed. This can be used to set the modal to be closed.() => {}
onCancelfunctionCallback that fires when the cancel button, x button, or backdrop is clicked. This can be used to set the modal to be closed.() => {}
titlestringTitle text to display above the main content text.
childrennodeChildren that will be rendered inside <ConfirmationModal /> component.
buttonTextstringText content of the confirmation button.
variant'default', 'danger'Sets the style variant.'default'
requiredInputTextstringIf provided, a text prompt will be displayed and the confirmation button will be disabled until the text prompt is filled out with the required text.
classNamestringStyle to be applied to the container's root node.
submitDisabledbooleanDetermines if the submit button should appear as disabledfalse
darkModebooleanDetermines if the component will appear in dark mode.false
5.0.14

24 days ago

5.0.13

1 month ago

5.0.12

1 month ago

5.0.11

2 months ago

5.0.10

2 months ago

5.0.9

3 months ago

5.0.0-alpha.1

10 months ago

5.0.0-alpha.0

10 months ago

4.0.10

11 months ago

5.0.8

7 months ago

5.0.7

8 months ago

5.0.6

8 months ago

5.0.5

9 months ago

5.0.4

9 months ago

5.0.3

9 months ago

5.0.2

10 months ago

5.0.1

10 months ago

5.0.0

10 months ago

4.0.8-next.6

12 months ago

4.0.8-next.7

12 months ago

4.0.8-next.0

12 months ago

4.0.8-next.1

12 months ago

4.0.8-next.4

12 months ago

4.0.8-next.5

12 months ago

4.0.8-next.2

12 months ago

4.0.8-next.3

12 months ago

4.0.7

12 months ago

4.0.9

11 months ago

4.0.8

11 months ago

4.0.5

1 year ago

4.0.6

1 year ago

4.0.4

1 year ago

4.0.3

1 year ago

3.1.4

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.2

1 year ago

3.1.0-test.1

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.0-test.0

2 years ago

3.1.0-next.1

2 years ago

3.1.0-next.0

2 years ago

3.1.0-next.2

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.4

2 years ago

3.0.5

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago