2.0.3 • Public • Published

    Prescrypto Elements

    A collection of custom elements for implementing the functionality of

    Quick Start


    <!-- 1. Load the PrescryptoElements library in the global scope  -->
    <script src=""></script>
    <!-- 2. Register a custom element, in this example the prescription history widget PrxPrescriptions -->
    <script type="text/javascript">
      customElements.define("prx-prescriptions", PrescryptoElements.PrxPrescriptions);
    <!-- 3. Add PrxPrescriptions with the required attributes to the HTML -->
    <prx-prescriptions token="mi-token-prescrypto"></prx-prescriptions>


    1. Install prescrypto-elements.

      # NPM
      npm install prescrypto-elements --save
      # Yarn
      yarn add prescrypto-elements
    2. Add an element to append PrxPrescriptions to.

        <div id="prx-app"></div>
    3. Import and register the custom element.

      import { PrxPrescriptions } from "prescrypto-elements";
      // Must run in the browser so the customElements method is available
      customElements.define("prx-prescriptions", PrxPrescriptions);
      // Create an instance of the custom element with the JavaScript API
      const prx = new PrxPrescriptions({ token: "mi-token-prescrypto" });
      // Add the element to the DOM


    Prescrypto's custom elements are encapsulated in Shadow DOM. Due to this reason, you can not apply styles with .class o #id, instead you must use ::part(). Below you can see an example of the DOM nodes used to render PrxPrescriptions. Note the part attributes.

    <table part="table">
      <thead part="thead">
        <tr part="tr trhead">
          <th part="th">ID</th>
          <th part="th">Patient</th>
          <th part="th">Email</th>
          <th part="th">Diagnosis</th>
          <th part="th">Date</th>
      <tbody part="tbody">
        <tr part="tr trbody">
          <td part="td td-id">{{ id }}</td>
          <td part="td td-name">{{ }}</td>
          <td part="td td-email">{{ }}</td>
          <td part="td td-diagnosis">{{ diagnosis }}</td>
          <td part="td td-creater">{{ created_at }}</td>

    To style the PrxPrescriptions component, those parts can be addressed via pseudo-selectors:

    prx-prescriptions {
      font-family: "Roboto", sans-serif;
      font-size: 14px;
    /* Styles for the <table> element */
    prx-prescriptions::part(table) {
      border-collapse: collapse;
      text-overflow: ellipsis;
    /* Styles for the <tr> element */
    prx-prescriptions::part(tr) {
      white-space: nowrap;
    /* Styles for the <thead> element */
    prx-prescriptions::part(thead) {
      font-size: 12px;
      font-weight: 500;
      line-height: 1.5;
      color: #627282;
      text-transform: uppercase;
      text-align: left;
    /* Styles for the <th> element */
    prx-prescriptions::part(th) {
      padding: 13px;
    /* Styles for the <tr> element inside of <thead> */
    prx-prescriptions::part(trhead) {
      border-bottom: 1px solid #edeff2;
    /* Styles for the <tr> element inside of <tbhody> */
    prx-prescriptions::part(trbody) {
      border-bottom: 1px solid #dcdfe3;
    /* Styles for the <td> element */
    prx-prescriptions::part(td) {
      color: #1b2734;
      line-height: 1.5;
      padding: 13px;
    /* Style for the <td> with the id */
    prx-prescriptions::part(td-id) {
      font-weight: 700;
    /* Style for the <td> with the name */
    prx-prescriptions::part(td-name) {
      font-weight: 700;




    npm i prescrypto-elements

    DownloadsWeekly Downloads






    Unpacked Size

    214 kB

    Total Files


    Last publish


    • disusered