Skip to content
Versions v4 v3 v2 v1

Search Input

A search input lets users type in words to find specific items or information. As they type, it can show matching results to help them quickly find what they are looking for.

Installation

We recommend loading elements via a CDN such as JSPM and using an import map to manage your dependencies.

For more information on import maps and how to use them, see the import map reference on MDN Web Docs.

If you are using node and NPM, you can install this component using npm:

npm install @patternfly/elements

Then import this component into your project by using a bare module specifier:

import '@patternfly/elements/pf-search-input/pf-search-input.js';

Please Note You should either load elements via a CDN or install them locally through NPM. Do not do both.

Overview

Blue Black Brown Bronze Green Magenta Orange Purple Periwinkle Pink Red Yellow

Installation

npm install @patternfly/elements

Usage

Search Input

What is Red Hat Enterprise Linux? How does Red Hat OpenShift work? Why use Red Hat Ansible for automation? Where can Red Hat OpenShift be deployed? When should you use Red Hat Enterprise Linux? What is Red Hat Satellite? How does Red Hat integrate with AWS and other clouds? Why choose Red Hat over other Linux vendors? Where can I learn Red Hat technologies? When does support end for RHEL versions? What are Red Hat certifications? How do you secure a RHEL server? Why use OpenShift instead of vanilla Kubernetes? Where is Red Hat headquartered? When should you use Red Hat CoreOS? What is Red Hat Insights? How do you manage Red Hat subscriptions? Why is RHEL considered enterprise-grade? Where can I download RHEL for testing? When was Red Hat founded?
View HTML Source
<div class="container">
<pf-search-input id="search-input" placeholder="Search">
  <pf-option>What is Red Hat Enterprise Linux?</pf-option>
  <pf-option>How does Red Hat OpenShift work?</pf-option>
  <pf-option>Why use Red Hat Ansible for automation?</pf-option>
  <pf-option>Where can Red Hat OpenShift be deployed?</pf-option>
  <pf-option>When should you use Red Hat Enterprise Linux?</pf-option>
  <pf-option>What is Red Hat Satellite?</pf-option>
  <pf-option>How does Red Hat integrate with AWS and other clouds?</pf-option>
  <pf-option>Why choose Red Hat over other Linux vendors?</pf-option>
  <pf-option>Where can I learn Red Hat technologies?</pf-option>
  <pf-option>When does support end for RHEL versions?</pf-option>
  <pf-option>What are Red Hat certifications?</pf-option>
  <pf-option>How do you secure a RHEL server?</pf-option>
  <pf-option>Why use OpenShift instead of vanilla Kubernetes?</pf-option>
  <pf-option>Where is Red Hat headquartered?</pf-option>
  <pf-option>When should you use Red Hat CoreOS?</pf-option>
  <pf-option>What is Red Hat Insights?</pf-option>
  <pf-option>How do you manage Red Hat subscriptions?</pf-option>
  <pf-option>Why is RHEL considered enterprise-grade?</pf-option>
  <pf-option>Where can I download RHEL for testing?</pf-option>
  <pf-option>When was Red Hat founded?</pf-option>
</pf-search-input>
</div>

<script type="module"> import '@patternfly/elements/pf-search-input/pf-search-input.js';

const searchInput = document.getElementById('search-input');

searchInput.addEventListener('change', (event) => { /* eslint-disable no-console / console.log('Selected:', event.target.value); / eslint-disable no-console */ }); </script>

<style> .container { padding: 40px; } </style>

Search Input Form

Alabama New Jersey New York New Mexico North Carolina Alabama 1 New Jersey 1 New York 1 New Mexico 1 North Carolina 1 Alabama 2 New Jersey 2 New York 2 New Mexico 2 North Carolina 2 Alabama 3 New Jersey 3 New York 3 New Mexico 3 North Carolina 3 Search
View HTML Source
<form class="container">
<div class="search-input-container">
  <pf-search-input id="search-input" name="search" placeholder="Search">
    <pf-option value="Alabama"> Alabama </pf-option>
    <pf-option value="New Jersey"> New Jersey </pf-option>
    <pf-option value="New York"> New York </pf-option>
    <pf-option value="New Mexico"> New Mexico </pf-option>
    <pf-option value="North Carolina"> North Carolina </pf-option>
    <pf-option value="Alabama1"> Alabama 1 </pf-option>
    <pf-option value="New Jersey1"> New Jersey 1 </pf-option>
    <pf-option value="New York1"> New York 1 </pf-option>
    <pf-option value="New Mexico1"> New Mexico 1</pf-option>
    <pf-option value="North Carolina1"> North Carolina 1</pf-option>
    <pf-option value="Alabama2"> Alabama 2 </pf-option>
    <pf-option value="New Jersey2"> New Jersey 2 </pf-option>
    <pf-option value="New York2"> New York 2 </pf-option>
    <pf-option value="New Mexico2"> New Mexico 2 </pf-option>
    <pf-option value="North Carolina2"> North Carolina 2 </pf-option>
    <pf-option value="Alabama3"> Alabama 3 </pf-option>
    <pf-option value="New Jersey3"> New Jersey 3 </pf-option>
    <pf-option value="New York3"> New York 3 </pf-option>
    <pf-option value="New Mexico3"> New Mexico 3 </pf-option>
    <pf-option value="North Carolina3"> North Carolina 3 </pf-option>
  </pf-search-input>
  <pf-button> Search</pf-button>
</div>
</form>

<script type="module"> import '@patternfly/elements/pf-search-input/pf-search-input.js';

const searchInput = document.getElementById('search-input');

searchInput.addEventListener('change', (event) => { /* eslint-disable no-console / console.log('Selected:', event.target.value); / eslint-disable no-console */ });

const form = document.querySelector('form.container'); form.addEventListener('submit', (event) =>{ event.preventDefault(); /* eslint-disable no-console / console.log("Value:", form.elements.search?.value); / eslint-disable no-console */ }) </script>

<style> .container { padding: 40px; .search-input-container { display: flex; align-items: center; justify-content: flex-start; #search-input { margin-right: 1rem; } } } </style>

Disabled

Blue Green Magenta Orange Purple Periwinkle Pink Red Yellow Search
View HTML Source
<form class="container">
<div class="search-input-container">
  <pf-search-input disabled id="search-input" name="search" placeholder="Search">
    <pf-option>Blue</pf-option>
    <pf-option>Green</pf-option>
    <pf-option>Magenta</pf-option>
    <pf-option>Orange</pf-option>
    <pf-option>Purple</pf-option>
    <pf-option>Periwinkle</pf-option>
    <pf-option>Pink</pf-option>
    <pf-option>Red</pf-option>
    <pf-option>Yellow</pf-option>
  </pf-search-input>
  <pf-button> Search</pf-button>
</div>
</form>

<script type="module"> import '@patternfly/elements/pf-search-input/pf-search-input.js'; </script>

<style> .container { padding: 40px; .search-input-container { display: flex; align-items: center; justify-content: flex-start; #search-input { margin-right: 1rem; } } } </style>

Accessibility

The search input uses the Combobox Pattern recommendations from the WAI ARIA Authoring Best Practices Guide (APG).

When the dropdown is disabled it follows WAI ARIA focusability recommendations for composite widget elements, where dropdown items are still focusable even when the dropdown is disabled.

Toggle and typeahead input

When focus is on the toggle, the following keyboard interactions apply:

Key Function
Down Arrow Opens the listbox and moves focus to the first listbox item.
Tab Moves focus to the close button if visible; otherwise, moves to the next focusable element, then closes the listbox.
Shift + Tab Moves focus out of element onto the previous focusable item and closes listbox.

Listbox options

Listbox options use the APG's Roving tabindex recommendation. When focus is on the listbox, the following keyboard interactions apply:

Key Function
Enter Selects the options and closes the listbox.
Space Selects the options and closes the listbox.
Tab Moves focus out of element onto the next focusable options and closes listbox.
Shift + Tab Moves focus to the toggle button and closes listbox.
Up Arrow Moves focus to the previous option, optionally wrapping from the first to the last.
Down Arrow Moves focus to the next option, optionally wrapping from the last to the first.
Left Arrow Returns focus to the combobox without closing the popup and moves the input cursor one character to the left. If the input cursor is on the left-most character, the cursor does not move.
Right Arrow Returns focus to the combobox without closing the popup and moves the input cursor one character to the right. If the input cursor is on the right-most character, the cursor does not move.
Escape Close the listbox that contains focus and return focus to the input.
Any letter Navigates to the next option that starts with the letter.

Slots on pf-search-input

Default Slot

insert <pf-option> and/or <pf-option-groups> here

Attributes on pf-search-input

accessible-label

Accessible label for the search input

DOM Property
accessibleLabel
Type
string
Default
unknown
disabled

Whether the search input is disabled

DOM Property
disabled
Type
boolean
Default
false
expanded

Whether the search input's listbox is expanded

DOM Property
expanded
Type
boolean
Default
false
value

Current form value

DOM Property
value
Type
string
Default
unknown
placeholder

Placeholder entry. Overridden by the placeholder slot

DOM Property
placeholder
Type
string
Default
unknown
position

Indicates initial popover position. There are 6 options: bottom, top, top-start, top-end, bottom-start, bottom-end. Default is bottom.

DOM Property
position
Type
Placement
Default
'bottom'

Methods on pf-search-input

show()

Opens the dropdown

hide()

Closes listbox

toggle()

toggles popup based on current state

Events on pf-search-input

open

when the menu toggles open

Event Type:
unknown
close

when the menu toggles closed

Event Type:
unknown

CSS Custom Properties on pf-search-input

CSS Property Description Default
--pf-global--spacer--form-element 0.375rem
--pf-global--target-size--MinWidth 44px
--pf-global--FontSize--md 1rem
--pf-global--FontWeight--normal 400
--pf-global--LineHeight--md 1.5
--pf-global--BorderColor--200 #8a8d90
--pf-global--BorderColor--300 #f0f0f0
--pf-global--active-color--100 #06c
--pf-global--disabled-color--300 #f0f0f0
--pf-global--danger-color--100 #c9190b
--pf-global--success-color--100 #3e8635
--pf-global--BorderWidth--md 2px
--pf-global--warning-color--100 #f0ab00
--pf-global--spacer--lg 1.5rem
--pf-global--Color--200 #6a6e73
--pf-global--Color--100 #151515
--pf-theme--color--surface--lightest #fff
--pf-c-search-input__menu-content--MaxHeight 20rem
--pf-c-list__item-icon--Color #6a6e73
--pf-c-search-input__toggle--BackgroundColor #fff
--pf-global--FontFamily--sans-serif "RedHatTextUpdated", "Overpass", overpass, helvetica, arial, sans-serif
--pf-c-search-input__toggle--FontSize 1rem
--pf-c-search-input__toggle--FontWeight 400
--pf-c-search-input__toggle--LineHeight 1.5
--pf-theme--color--text #151515
--pf-global--Color--dark-200 #6a6e73
--pf-theme--color--surface--lighter #f0f0f0
--pf-global--spacer--sm 0.5rem
--pf-global--BorderWidth--sm 1px
--pf-c-divider--BackgroundColor
--pf-global--BorderColor--100 #d2d2d2
--pf-c-divider--BorderColor--base
--pf-c-divider--Height
--pf-c-divider--BorderWidth--base
--pf-c-divider--m-horizontal--Display
--pf-c-divider--m-horizontal--FlexDirection
--pf-c-divider--m-horizontal--after--Width
--pf-c-divider--m-horizontal--after--Height
--pf-c-divider--Display flex
--pf-c-divider--FlexDirection
--pf-c-search-input-menu--c-divider--MarginTop
--pf-c-search-input-menu--c-divider--MarginBottom
--pf-c-divider--after--Width 100%
--pf-c-divider--after--Height 1px
--pf-c-divider--after--BackgroundColor
--pf-global--spacer--md 1rem
--pf-global--spacer--xs 0.125rem
--pf-theme--color--accent #0066cc
--pf-global--BackgroundColor--100 #fff

CSS Parts on pf-search-input

None

Slots on pf-option

icon

icon optional icon

create
Default Slot

option text

description

description optional description

Attributes on pf-option

disabled

whether option is disabled

DOM Property
disabled
Type
boolean
Default
false
value

form value for this option

DOM Property
value
Type
unknown
Default
unknown
selected

whether option is selected

DOM Property
selected
Type
boolean
Default
false
active

whether option is active descendant

DOM Property
active
Type
boolean
Default
false
description

Optional option description; overridden by description slot.

DOM Property
description
Type
string
Default
''

Methods on pf-option

None

Events on pf-option

None

CSS Custom Properties on pf-option

CSS Property Description Default
--rh-color-gray-20 #e0e0e0
--pf-global--spacer--sm 0.5rem
--pf-global--spacer--md 1rem
--pf-theme--color--surface--lighter #f0f0f0
--pf-c-select__menu-item-icon--FontSize var(--pf-global--icon--FontSize--sm, 0.675rem)
--pf-global--icon--FontSize--sm 0.675rem
--pf-theme--color--accent #0066cc
--pf-global--FontSize--xs 0.75rem
--pf-global--Color--dark-200 #6a6e73

CSS Parts on pf-option

None

© 2018-2025 Red Hat, Inc. Deploys by Netlify