Socket
Socket
Sign inDemoInstall

@patternfly/pfe-select

Package Overview
Dependencies
8
Maintainers
16
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @patternfly/pfe-select

Select element for PatternFly Elements


Version published
Weekly downloads
212
decreased by-20.9%
Maintainers
16
Created
Weekly downloads
 

Readme

Source

PatternFly Elements Select

The select component provides a way to create list of options in a form.

Read more about Select in the PatternFly Elements Select documentation

Installation

Load <pfe-select> via CDN:

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

Or, if you are using NPM, install it

npm install @patternfly/pfe-select

Then once installed, import it to your application:

import '@patternfly/pfe-select';

Usage

There are 3 ways of providing options to your component:

  • Users can provide options using <select> element inside <pfe-select>
  • Users can set custom options as an array of objects on the element's options property
  • Users can append more options by using the element's addOptions() method

Note: <pfe-select> component can also be used in places where dropdowns are needed but its more suitable for forms. For dropdowns, <pfe-dropdown> is preferred.

With <select> element:

<pfe-select>
  <select>
    <option disabled>Please select an option</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
</pfe-select>

Without <select> element:

<pfe-select></pfe-select>

For custom options, use the options setter to set the options as shown in snippet below:

const select = document.querySelector("pfe-select");
select.options = [
  { text: "Please select an option", value: "", selected: true },
  { text: 'One', value: '1', selected: false },
  { text: 'Two', value: '2', selected: false },
  { text: 'Three', value: '3', selected: false}
];

Keywords

FAQs

Last updated on 23 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc