• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

Dropdown

<Dropdown> are toggleable overlays for displaying a list of options.

The <Dropdown> component can render the items in two ways: as an array of <DropdownItem> elements or as a render callback (Function as Children).

The recommendation is to use the render callback when a large number of items is provided because then the dropdown will virtualize all the items and performance will be greatly improve.

If you are willing to use <Dropdown> to paint a select field as you would do in a form, use <Select> instead.

The component also supports nested lists, check out the DropdownItem documentation to learn more.

Usage

import { Dropdown } from 'nr1'

Examples

Basic

<Dropdown title="Dropdown">
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem>Item 3</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>

With label and info

<Dropdown title="Dropdown" label="Items" info="Info value">
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem>Item 3</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>

With inline label

<Dropdown title="Dropdown" label="Items" labelInline>
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem>Item 3</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>

With description

<Dropdown title="Dropdown" description="Description value">
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem>Item 3</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>

With Invalid message

<Dropdown title="Dropdown" invalid="Invalid message value">
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem>Item 3</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>

With sub items

function render() {
const items = new Array(10).fill().map((_, i) => i + 1);
return (
<Dropdown title="Dropdown">
<DropdownItem>Item 1</DropdownItem>
<DropdownItem onClick={(evt) => console.log(evt)}>Item 2</DropdownItem>
<DropdownItem items={items}>
Item 3
{({ item, index }) => (
<DropdownItem key={index} onClick={(evt) => console.log(evt)}>
Item 3.{item}
</DropdownItem>
)}
</DropdownItem>
<DropdownItem>Item 4</DropdownItem>
</Dropdown>
);
}

Sections

<Dropdown title="Dropdown" sectioned>
<DropdownSection title="Section 1">
<DropdownItem>Item 1.1</DropdownItem>
<DropdownItem>Item 1.2</DropdownItem>
</DropdownSection>
<DropdownSection title="Section 2">
<DropdownItem>Item 2.1</DropdownItem>
<DropdownItem>Item 2.2</DropdownItem>
</DropdownSection>
</Dropdown>

Virtualized list

function render() {
const items = new Array(10000).fill().map((_, i) => `Item ${i}`);
return (
<Dropdown title="Dropdown" items={items}>
{({ item, index }) => (
<DropdownItem key={index} onClick={() => alert(item)}>
{item}
</DropdownItem>
)}
</Dropdown>
);
}

Virtualized sections and items list

function render() {
const sections = new Array(30).fill().map((_, s) => ({
title: `Section ${s}`,
items: new Array(1000).fill().map((_, i) => `Item ${s}.${i}`),
}));
return (
<Dropdown title="Dropdown" items={sections} sectioned>
{({ item: section, index }) => (
<DropdownSection
key={index}
title={section.title}
items={section.items}
>
{({ item, index }) => <DropdownItem>{item}</DropdownItem>}
</DropdownSection>
)}
</Dropdown>
);
}

Search prop and onSearch callback

class SearchDropdown extends React.Component {
constructor() {
super(...arguments);
this.state = {
search: '',
items: [
{ id: '1ed6', name: 'Melton Garcia' },
{ id: 'f5a3', name: 'Finley Mendez' },
{ id: '93bc', name: 'Coleen Salinas' },
{ id: '7123', name: 'John Doe' },
{ id: 'b62f', name: 'Ana Santos' },
{ id: '8db4', name: 'Jane Smith' },
{ id: '4c77', name: 'Colin Payne' },
],
};
}
render() {
const { search, items } = this.state;
const filteredItems = items.filter(({ name }) =>
name.toLowerCase().includes(search.toLowerCase()),
);
return (
<Dropdown
title="Dropdown"
items={filteredItems}
search={search}
onSearch={(evt) => this.setState({ search: evt.target.value })}
>
{({ item }) => <DropdownItem key={item.id}>{item.name}</DropdownItem>}
</Dropdown>
);
}
}

Props

ariaLabel

string

Provide a descriptive label for this control, e.g. "Accounts".

children

REQUIRED
node|function

This component can render either declaratively, by directly passing a set of children or virtualized, by passing a render callback (function as children).Children can be of two types: <DropdownItem>s, to generate items; or <DropdownSection>s, when the dropdown is sectioned. Each section can, in turn, have <DropdownItem>s in it.The recommendation is to use the render callback when a large number of items is provided, since the item list will be virtualized by the component, thus increasing the performance.When using the render callback, items need to be provided through the items prop. Then, the callback will be called for each item present in the array, and the expected result is a <DropdownItem> or a <DropdownSection> depending on the sectioned prop.

className

string

Appends class names to the component.Should be used only for positioning and spacing purposes.

description

string

Message with instructions on how to fill the form field.

disabled

boolean

If true, the dropdown is not available for interaction.

iconType

enum

Icon to display. <One of


Dropdown.ICON_TYPE.DATAVIZDATAVIZAREA_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZBAR_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZBILLBOARD_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZBULLET_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZCHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZCHARTA_ADD, Dropdown.ICON_TYPE.DATAVIZDATAVIZCHARTA_EDIT, Dropdown.ICON_TYPE.DATAVIZDATAVIZCHARTA_REMOVE, Dropdown.ICON_TYPE.DATAVIZDATAVIZDASHBOARD, Dropdown.ICON_TYPE.DATAVIZDATAVIZDASHBOARDA_ADD, Dropdown.ICON_TYPE.DATAVIZDATAVIZDASHBOARDA_EDIT, Dropdown.ICON_TYPE.DATAVIZDATAVIZDASHBOARDA_FILTER, Dropdown.ICON_TYPE.DATAVIZDATAVIZDASHBOARDA_REMOVE, Dropdown.ICON_TYPE.DATAVIZDATAVIZEVENT_FEED_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZHEATMAP_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZLINE_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZMARKDOWN, Dropdown.ICON_TYPE.DATAVIZDATAVIZPIE_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZSCATTER_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZSERVICE_MAP_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZSTACKED_BAR_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZSTACKED_HORIZONTAL_BAR_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZTABLE_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZTRAFFIC_LIGHTS_CHART, Dropdown.ICON_TYPE.DATAVIZDATAVIZVERTICAL_BAR_CHART, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMEDATE, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMEDATEA_ADD, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMEDATEA_REMOVE, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMETIME, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMETIMEA_ADD, Dropdown.ICON_TYPE.DATE_AND_TIMEDATE_AND_TIMETIMEA_REMOVE, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSATTACHMENT, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSDOCUMENTATION, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSEMAIL, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSEMAILV_ALTERNATE, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFILE, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFILEA_ADD, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFILEA_REMOVE, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFOLDER, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFOLDERA_ADD, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSFOLDERA_REMOVE, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSNOTES, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSNOTESA_ADD, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSNOTESA_EDIT, Dropdown.ICON_TYPE.DOCUMENTSDOCUMENTSNOTESA_REMOVE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREANOMALIES, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTERA_INSPECT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTERS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTERS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTERS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECLUSTERS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARECPU, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREDESKTOP, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREDESKTOPS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREDESKTOPS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREDESKTOPS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREDESKTOPS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMEMORY, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILEA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILES_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILES_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILES_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWAREMOBILES_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORKA_INSPECT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORKS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORKS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORKS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARENETWORKS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_ADD, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_CONFIGURE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_EDIT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_INSPECT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_PAUSE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERA_REMOVE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESERVERS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREHARDWARESTORAGE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_CLUSTER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_CONTAINER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_DEPLOYMENT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_MASTER_NODE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_NAMESPACE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_NODE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_POD, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWAREKUBERNETESK8S_SERVICE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREALL_ENTITIES, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATION, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATIONA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATIONS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATIONS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATIONS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREAPPLICATIONS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSERA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSERS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSERS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSERS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREBROWSERS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECLOUD, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECODE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECONTAINER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECONTROL_CENTER, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECORRELATION, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARECORRELATION_REASONING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASEA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASES_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASES_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASES_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDATABASES_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDECISIONS, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDESTINATIONS, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDOWNSTREAM_CONNECTION, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREDOWNSTREAM_DEPLOYMENT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREEVENT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREFEED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARELIVE_VIEW, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARELOGS, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATION, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATIONA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATIONS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATIONS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATIONS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMOBILE_APPLICATIONS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREMONITORING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARENODE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREOVERVIEW, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPATHWAY, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGIN, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGINA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGINS_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGINS_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGINS_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREPLUGINS_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREQUERY, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICEA_CHECKED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICES_DISABLED, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICES_ERROR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICES_OK, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESERVICES_WARNING, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESOURCES, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESTACK_TRACE, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESYNTHESIZED_ENTITY, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESYNTHETICS_MONITOR, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARESYSTEM, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARETRACES, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWARETRAFFIC, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREUPSTREAM_CONNECTION, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREUPSTREAM_DEPLOYMENT, Dropdown.ICON_TYPE.HARDWARE_AND_SOFTWARESOFTWAREWORKLOADS, Dropdown.ICON_TYPE.INTERFACEARROWARROW_BOTTOM, Dropdown.ICON_TYPE.INTERFACEARROWARROW_BOTTOMV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEARROWARROW_BOTTOMV_ALTERNATEWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEARROWARROW_DIAGONAL_BOTTOM_LEFT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_DIAGONAL_BOTTOM_RIGHT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_DIAGONAL_TOP_LEFT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_DIAGONAL_TOP_RIGHT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_HORIZONTAL, Dropdown.ICON_TYPE.INTERFACEARROWARROW_LEFT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_LEFTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEARROWARROW_LEFTV_ALTERNATEWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEARROWARROW_RIGHT, Dropdown.ICON_TYPE.INTERFACEARROWARROW_RIGHTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEARROWARROW_RIGHTV_ALTERNATEWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEARROWARROW_TOP, Dropdown.ICON_TYPE.INTERFACEARROWARROW_TOPV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEARROWARROW_TOPV_ALTERNATEWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEARROWARROW_VERTICAL, Dropdown.ICON_TYPE.INTERFACEARROWEXPAND, Dropdown.ICON_TYPE.INTERFACEARROWGO_TO, Dropdown.ICON_TYPE.INTERFACEARROWMOVE, Dropdown.ICON_TYPE.INTERFACEARROWRESIZE, Dropdown.ICON_TYPE.INTERFACEARROWRETURN_LEFT, Dropdown.ICON_TYPE.INTERFACEARROWRETURN_RIGHT, Dropdown.ICON_TYPE.INTERFACEARROWSHRINK, Dropdown.ICON_TYPE.INTERFACEARROWSORT, Dropdown.ICON_TYPE.INTERFACECARETCARET_BOTTOM, Dropdown.ICON_TYPE.INTERFACECARETCARET_BOTTOMSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_BOTTOMV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECARETCARET_BOTTOMWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECARETCARET_BOTTOMWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_LEFT, Dropdown.ICON_TYPE.INTERFACECARETCARET_LEFTSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_LEFTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECARETCARET_LEFTWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECARETCARET_LEFTWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_RIGHT, Dropdown.ICON_TYPE.INTERFACECARETCARET_RIGHTSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_RIGHTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECARETCARET_RIGHTWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECARETCARET_RIGHTWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_TOP, Dropdown.ICON_TYPE.INTERFACECARETCARET_TOPSIZE_8, Dropdown.ICON_TYPE.INTERFACECARETCARET_TOPV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECARETCARET_TOPWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECARETCARET_TOPWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_BOTTOM, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_BOTTOMSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_BOTTOMV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_BOTTOMWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_BOTTOMWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_LEFT, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_LEFTSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_LEFTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_LEFTWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_LEFTWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_RIGHT, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_RIGHTSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_RIGHTV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_RIGHTWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_RIGHTWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_TOP, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_TOPSIZE_8, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_TOPV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_TOPWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACECHEVRONCHEVRON_TOPWEIGHT_BOLDSIZE_8, Dropdown.ICON_TYPE.INTERFACEINFOANNOUNCEMENT, Dropdown.ICON_TYPE.INTERFACEINFOHELP, Dropdown.ICON_TYPE.INTERFACEINFOINFO, Dropdown.ICON_TYPE.INTERFACEINFOINFOWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEOPERATIONSADJUST, Dropdown.ICON_TYPE.INTERFACEOPERATIONSALERT, Dropdown.ICON_TYPE.INTERFACEOPERATIONSALERTA_REMOVE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSALERTS_OFF, Dropdown.ICON_TYPE.INTERFACEOPERATIONSALERTS_ON, Dropdown.ICON_TYPE.INTERFACEOPERATIONSARCHIVE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCENTER, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCLOSE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCLOSESIZE_8, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCLOSEV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCONFIGURE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCOPY_TO, Dropdown.ICON_TYPE.INTERFACEOPERATIONSCOPY_TO_CLIPBOARD, Dropdown.ICON_TYPE.INTERFACEOPERATIONSDOWNLOAD, Dropdown.ICON_TYPE.INTERFACEOPERATIONSDRAG, Dropdown.ICON_TYPE.INTERFACEOPERATIONSEDIT, Dropdown.ICON_TYPE.INTERFACEOPERATIONSEXPORT, Dropdown.ICON_TYPE.INTERFACEOPERATIONSEXTERNAL_LINK, Dropdown.ICON_TYPE.INTERFACEOPERATIONSFILTER, Dropdown.ICON_TYPE.INTERFACEOPERATIONSFILTERA_ADD, Dropdown.ICON_TYPE.INTERFACEOPERATIONSFILTERA_REMOVE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSFILTERV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSFOLLOW, Dropdown.ICON_TYPE.INTERFACEOPERATIONSGROUP, Dropdown.ICON_TYPE.INTERFACEOPERATIONSGROUPA_REMOVE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSGROUPV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSHIDE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSHIDE_OTHERS, Dropdown.ICON_TYPE.INTERFACEOPERATIONSHIGHLIGHT, Dropdown.ICON_TYPE.INTERFACEOPERATIONSIMPORT, Dropdown.ICON_TYPE.INTERFACEOPERATIONSMORE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSPAUSE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSPAUSE_ALTERNATEV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSPIN, Dropdown.ICON_TYPE.INTERFACEOPERATIONSPLAY, Dropdown.ICON_TYPE.INTERFACEOPERATIONSPLAY_ALTERNATEV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSREARRANGE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSREDO, Dropdown.ICON_TYPE.INTERFACEOPERATIONSREFRESH, Dropdown.ICON_TYPE.INTERFACEOPERATIONSREMOVEV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSREPLYA_REPLY, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSEARCH, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSEARCHV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSELECTION, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSELECTIONV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSHARE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSHARE_LINK, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSHOW, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSKIP_BACK, Dropdown.ICON_TYPE.INTERFACEOPERATIONSSKIP_FORWARD, Dropdown.ICON_TYPE.INTERFACEOPERATIONSTAG, Dropdown.ICON_TYPE.INTERFACEOPERATIONSTRASH, Dropdown.ICON_TYPE.INTERFACEOPERATIONSTV_MODE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSTV_MODEA_TV_MODE, Dropdown.ICON_TYPE.INTERFACEOPERATIONSUNDO, Dropdown.ICON_TYPE.INTERFACEOPERATIONSUNPIN, Dropdown.ICON_TYPE.INTERFACEOPERATIONSUPLOAD, Dropdown.ICON_TYPE.INTERFACEPLACEHOLDERSCUSTOM_PLACEHOLDER, Dropdown.ICON_TYPE.INTERFACEPLACEHOLDERSICON_PLACEHOLDER, Dropdown.ICON_TYPE.INTERFACESIGNASTERISK, Dropdown.ICON_TYPE.INTERFACESIGNCHECKMARK, Dropdown.ICON_TYPE.INTERFACESIGNCHECKMARKV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACESIGNCHECKMARKV_ALTERNATEWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACESIGNCLOSE, Dropdown.ICON_TYPE.INTERFACESIGNDOLLAR_SIGN, Dropdown.ICON_TYPE.INTERFACESIGNEXCLAMATION, Dropdown.ICON_TYPE.INTERFACESIGNEXCLAMATIONV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACESIGNMINUS, Dropdown.ICON_TYPE.INTERFACESIGNMINUSV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACESIGNNUMBER, Dropdown.ICON_TYPE.INTERFACESIGNPLUS, Dropdown.ICON_TYPE.INTERFACESIGNPLUSV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACESIGNTIMES, Dropdown.ICON_TYPE.INTERFACESIGNTIMESSIZE_8, Dropdown.ICON_TYPE.INTERFACESIGNTIMESV_ALTERNATE, Dropdown.ICON_TYPE.INTERFACESTATECLOSED, Dropdown.ICON_TYPE.INTERFACESTATECRITICAL, Dropdown.ICON_TYPE.INTERFACESTATECRITICALWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACESTATEDISABLED, Dropdown.ICON_TYPE.INTERFACESTATEENABLED, Dropdown.ICON_TYPE.INTERFACESTATEHEALTHY, Dropdown.ICON_TYPE.INTERFACESTATELOADING, Dropdown.ICON_TYPE.INTERFACESTATELOCK, Dropdown.ICON_TYPE.INTERFACESTATEOPEN, Dropdown.ICON_TYPE.INTERFACESTATEPRIVATE, Dropdown.ICON_TYPE.INTERFACESTATEPUBLIC, Dropdown.ICON_TYPE.INTERFACESTATEUNAVAILABLE, Dropdown.ICON_TYPE.INTERFACESTATEUNLOCK, Dropdown.ICON_TYPE.INTERFACESTATEWARNING, Dropdown.ICON_TYPE.INTERFACESTATEWARNINGWEIGHT_BOLD, Dropdown.ICON_TYPE.INTERFACEVIEWENTER_FULL_SCREEN, Dropdown.ICON_TYPE.INTERFACEVIEWEXIT_FULL_SCREEN, Dropdown.ICON_TYPE.INTERFACEVIEWGRID_VIEW, Dropdown.ICON_TYPE.INTERFACEVIEWHIGH_DENSITY_VIEW, Dropdown.ICON_TYPE.INTERFACEVIEWLAYER_LIST, Dropdown.ICON_TYPE.INTERFACEVIEWLIST_VIEW, Dropdown.ICON_TYPE.INTERFACEVIEWSIXTH_SENSE, Dropdown.ICON_TYPE.INTERFACEVIEWTHEME_TOGGLE, Dropdown.ICON_TYPE.INTERFACEVIEWTHEME_TOGGLES_DARK, Dropdown.ICON_TYPE.INTERFACEVIEWTHEME_TOGGLES_LIGHT, Dropdown.ICON_TYPE.LOCATIONLOCATIONHOME, Dropdown.ICON_TYPE.LOCATIONLOCATIONMAP, Dropdown.ICON_TYPE.LOCATIONLOCATIONPIN, Dropdown.ICON_TYPE.LOCATIONLOCATIONWORLD, Dropdown.ICON_TYPE.PROFILESEVENTSCOMMENT, Dropdown.ICON_TYPE.PROFILESEVENTSCOMMENTA_EDIT, Dropdown.ICON_TYPE.PROFILESEVENTSFAVORITE, Dropdown.ICON_TYPE.PROFILESEVENTSFAVORITEWEIGHT_BOLD, Dropdown.ICON_TYPE.PROFILESEVENTSLIKE, Dropdown.ICON_TYPE.PROFILESUSERSORGANIZATION, Dropdown.ICON_TYPE.PROFILESUSERSORGANIZATIONA_ADD, Dropdown.ICON_TYPE.PROFILESUSERSORGANIZATIONA_EDIT, Dropdown.ICON_TYPE.PROFILESUSERSORGANIZATIONA_REMOVE, Dropdown.ICON_TYPE.PROFILESUSERSTEAM, Dropdown.ICON_TYPE.PROFILESUSERSTEAMA_ADD, Dropdown.ICON_TYPE.PROFILESUSERSTEAMA_EDIT, Dropdown.ICON_TYPE.PROFILESUSERSTEAMA_REMOVE, Dropdown.ICON_TYPE.PROFILESUSERSUSER, Dropdown.ICON_TYPE.PROFILESUSERSUSERA_ADD, Dropdown.ICON_TYPE.PROFILESUSERSUSERA_EDIT, Dropdown.ICON_TYPE.PROFILESUSERSUSER__A_REMOVE,
>

info

string

Additional information can be displayed in an info tooltip next to the Label.

invalid

boolean|string

When true, sets the field in an invalid state, in order to notify the user attention is needed over this particular field. This property can be a boolean field or a string. When it is a string, as well as the invalid state being shown, the text will be shown below.

items

array

Items to render, in the shape of a list of objects. Usually, each item in the items array contains the required data to generate the corresponding <DropdownItem> (or <DropdownSection> in case the dropdown is sectioned).This prop is required when rendering items with the render callback (function as children).

const items = ['Item 1', 'Item 2', 'Item 3'];
const dropdown = (
<Dropdown title="Dropdown" items={items}>
{({ item, index }) => (
<DropdownItem key={index} onClick={() => console.log(item)}>
{item}
</DropdownItem>
)}
</Dropdown>
);

label

string

Text to display as label.

labelInline

boolean

Display the label inline the form control.Use only when the component is not inside a Form. In that case set layoutType to Form.LAYOUT_TYPE.SPLIT in the Form component.

loading

boolean

To indicate whether an action is in progress, especially in the case that it takes more than 1 second to complete, you should display the loading state.

onClose

function

Callback fired any time the dropdown is closed.function (

event: React.MouseEvent
)

onLoadMore

function

Callback fired when more items must be loaded. This happens when you're lazy loading the items and the items that are about to render cannot be found in the items array.This callback should be used to fetch/load the missing items from the backend or other sources.The returned Promise should be resolved once item data has finished loading. It will be used to determine when to refresh the list with the newly-loaded data. This callback may be called multiple times in reaction to a single scroll event.

function (
cursor: Cursor

Items to load.

)

Lazy loading items

import { Dropdown, DropdownItem } from 'nr1';
// This example assumes you have a way to know/load this information.
const remoteTotalNumberOfItems = 9000;
const items = [
{ id: 1, text: 'Item 1' },
{ id: 2, text: 'Item 2' },
{ id: 3, text: 'Item 3' },
{ id: 4, text: 'Item 4' },
];
function fetchMore({ startIndex, stopIndex }) {
return fetch(
`path/to/api?startIndex=${startIndex}&stopIndex=${stopIndex}`
).then((response) => {
// Store items in item list...
});
}
const dropdown = (
<Dropdown
items={items}
onLoadMore={fetchMore}
rowCount={remoteTotalNumberOfItems}
title="Dropdown"
>
{({ item, index }) => <DropdownItem key={index}>{item.text}</DropdownItem>}
</Dropdown>
);

Integration with the query components

import { EntitiesByDomainTypeQuery, Dropdown, DropdownItem } from 'nr1';
const renderDropdown = (queryResult) => {
const { fetchMore, loading, data } = queryResult;
const { results, count } = data.actor.entitySearch;
return (
<Dropdown
items={results.entities}
onLoadMore={fetchMore}
rowCount={count}
title="Dropdown"
>
{({ item, index }) => (
<DropdownItem key={index}>{item.text}</DropdownItem>
)}
</Dropdown>
);
};
const style = { width: 200, height: 300 };
const dropdown = (
<EntitiesByDomainTypeQuery entityDomain="APM" entityType="APPLICATION">
{renderDropdown}
</EntitiesByDomainTypeQuery>
);

onOpen

function

Callback fired any time the dropdown is opened. function (

event: React.MouseEvent
)

onSearch

function

Callback fired any time the search input of the dropdown changes. This callback needs the search prop to be defined. function (

event: React.ChangeEvent
)

onToggle

function

Callback fired any time the dropdown is toggled. function (

event: React.MouseEvent,
opened: boolean
)

placementType

enum

Specifies the placement of the dropdown relative to the dropdown trigger. Default display is on the bottom start, but you can also choose to display it from the bottom end. <One of

Dropdown.PLACEMENT_TYPE.BOTTOM_END, Dropdown.PLACEMENT_TYPE.BOTTOM_START
>

required

boolean

If true, denotes the form field as required.

rowCount

number

Number of rows.By default it's equal to length of array passed in the items prop.You should specify the rowCount when you know the total number of items but you want to lazy load them while scrolling.

search

string

Value of the search input. The search input will be shown only if the value is defined.

sectioned

boolean

Establishes whether the dropdown is sectioned. A sectioned dropdown composes its options grouped by sections (made with <DropdownSection>), where each section is delimited by an optional title at the top, and a horizontal separator at the bottom.

spacingType

enum[]

Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like margin or padding. To omit a value, use SPACING_TYPE.OMIT. <Array of

<One of
Dropdown.SPACING_TYPE.EXTRA_LARGE, Dropdown.SPACING_TYPE.LARGE, Dropdown.SPACING_TYPE.MEDIUM, Dropdown.SPACING_TYPE.NONE, Dropdown.SPACING_TYPE.OMIT, Dropdown.SPACING_TYPE.SMALL,
>
>

style

object

Inline style for custom styling.Should be used only for positioning and spacing purposes.

testId

string

Adds a data-test-id attribute. Use it to target the component in unit and E2E tests.For a test id to be valid, prefix it with your nerdpack id, followed up by a dot.For example, my-nerdpack.some-element.Note: You might not see data-test-id attributes as they are removed from the DOM, to debug them pass a e2e-test query parameter to the URL.

title

string

The text to display in the dropdown button. When not present, an icon must be passed instead.

type

enum

Type can be:

  • Primary — use to call attention to one specific action you want the user to take as a next step.
  • Normal (used as secondary) — use when multiple actions need to be displayed.
  • Plain — use when multiple actions need to be available that are less important for the user to take.
  • Destructive — use when you have a destructive action like delete or remove, which you would like the user to pause and consider before completing. <One of
    Dropdown.TYPE.DESTRUCTIVE, Dropdown.TYPE.NORMAL, Dropdown.TYPE.PLAIN, Dropdown.TYPE.PLAIN_NEUTRAL, Dropdown.TYPE.PRIMARY,
    >

Type definitions

DropdownRendererArguments

{
item: string,

Item to render

index: number,

Index of the item in the items array

items: string[],

Array of items which we're iterating on

}

Cursor

{
startIndex: number,

First index of the range of items to load.

stopIndex: number,

Last index of the range of items to load.

}
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.