1.12.3 • Published 2 years ago

@patternfly/pfe-dropdown v1.12.3

Weekly downloads
63
License
MIT
Repository
github
Last release
2 years ago

PatternFly Elements Dropdown

This element will provide a dropdown menu of links and/or actions. It's comprised of one sub-component, pfe-dropdown-item , which denotes an item in the dropdown menu.

Read more about Dropdown in the PatternFly Elements Dropdown documentation

Installation

Load <pfe-dropdown> via CDN:

<script src="https://unpkg.com/@patternfly/pfe-dropdown?module"></script>

Or, if you are using NPM, install it

npm install @patternfly/pfe-dropdown

Then once installed, import it to your application:

import '@patternfly/pfe-dropdown';

Usage

<pfe-dropdown label="Dropdown">
  <pfe-dropdown-item item-type="link">
    <a href="https://bit.ly/3b9wvWg">Link 1</a>
  </pfe-dropdown-item>
  <pfe-dropdown-item item-type="link">
    <a href="https://bit.ly/3b9wvWg">Link 2</a>
  </pfe-dropdown-item>
  <pfe-dropdown-item item-type="link" disabled>
    <a href="https://bit.ly/3b9wvWg">Link 2</a>
  </pfe-dropdown-item>
  <pfe-dropdown-item item-type="separator"></pfe-dropdown-item>
  <pfe-dropdown-item item-type="action">
    <button>Action 1</button>
  </pfe-dropdown-item>
</pfe-dropdown>

You can also provide a list of dropdown items dynamically:

const dropdown = document.querySelector("pfe-dropdown");
dropdown.options = [
    {
        href: "https://bit.ly/3b9wvWg",
        text: "Link 1",
        type: "link",
        disabled: false
    },
    {
        href: "https://bit.ly/3b9wvWg",
        text: "Link 2",
        type: "link",
        disabled: false
    },
    {
        href: "https://bit.ly/3b9wvWg",
        text: "Link 3",
        type: "link",
        disabled: true
    },
    {
        type: "separator"
    },
    {
        text: "Action 1",
        type: "action",
        disabled: false
    },
    {
        text: "Action 2",
        type: "action",
        disabled: true
    }
];

Or you can add individual dropdown items with the addDropdownOptions method. Pass an array of pfe-dropdown-item objects to addDropdownOptions .

await dropdown.updateComplete;
dropdown.addDropdownOptions([{
    href: "https://bit.ly/3b9wvWg",
    text: "Link 4",
    type: "link",
    disabled: false
}]);
2.0.0-next.3

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.1

2 years ago

1.12.3

2 years ago

2.0.0-next.0

2 years ago

1.12.2

2 years ago

1.12.1

2 years ago

1.12.0

3 years ago

1.11.2

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.3

3 years ago

1.9.1

3 years ago

1.9.2

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago