Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

modal react form table

import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';

const customStyles = {
  content : {
    top                   : '50%',
    left                  : '50%',
    right                 : 'auto',
    bottom                : 'auto',
    marginRight           : '-50%',
    transform             : 'translate(-50%, -50%)'
  }
};

// Make sure to bind modal to your appElement (http://reactcommunity.org/react-modal/accessibility/)
Modal.setAppElement('#yourAppElement')

function App(){
  var subtitle;
  const [modalIsOpen,setIsOpen] = React.useState(false);
  function openModal() {
    setIsOpen(true);
  }

  function afterOpenModal() {
    // references are now sync'd and can be accessed.
    subtitle.style.color = '#f00';
  }

  function closeModal(){
    setIsOpen(false);
  }

    return (
      <div>
        <button onClick={openModal}>Open Modal</button>
        <Modal
          isOpen={modalIsOpen}
          onAfterOpen={afterOpenModal}
          onRequestClose={closeModal}
          style={customStyles}
          contentLabel="Example Modal"
        >

          <h2 ref={_subtitle => (subtitle = _subtitle)}>Hello</h2>
          <button onClick={closeModal}>close</button>
          <div>I am a modal</div>
          <form>
            <input />
            <button>tab navigation</button>
            <button>stays</button>
            <button>inside</button>
            <button>the modal</button>
          </form>
        </Modal>
      </div>
    );
}

ReactDOM.render(<App />, appElement);
Comment

PREVIOUS NEXT
Code Example
Javascript :: ValueError: dictionary update sequence element #0 has length 1; 2 is required 
Javascript :: react hooks example 
Javascript :: nodejs curd insert update delete 
Javascript :: getinitialprops to a hoc in next js 
Javascript :: flutter local json storage 
Javascript :: send as form data with boundry axios 
Javascript :: regex 1-31 days 
Javascript :: how to check alphabet case in javascript 
Javascript :: how to give default value in jquery 
Javascript :: difference between var, let, const 
Javascript :: why does javascript let you write a function without the parentheses 
Javascript :: how to alert in javascript 
Javascript :: hostlistner 
Javascript :: last row bold datatable 
Javascript :: vue date helper 
Javascript :: react convert table to pdf 
Javascript :: javascript download file 
Javascript :: how to assert input value in testing library 
Javascript :: div diseapear animation 
Javascript :: delete character between index 
Javascript :: change color in react 
Javascript :: handle multer error json 
Javascript :: write buffer to file in node 
Javascript :: splice javascript 
Javascript :: remove text in div jquery 
Javascript :: timestamp discord.js 
Javascript :: leaflet js mobile popup not opening 
Javascript :: remove an item from the end of an array 
Javascript :: find consecutive numbers in an array javascript 
Javascript :: js closure 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =