Skip to content

Properties

You may check out the DrawerList Properties down below as well as the Data structure examples.

PropertyTypeDescription
modestring(optional) If set to async, it prevents showing the "no options" message during typing / filtering. Defaults to sync.
input_valuestring(optional) Lets you define a custom input value.
placeholderstring(optional) Use this to define the pre-filled placeholder text in the input. Defaults to title="Skriv og velg".
titleReact.Node(optional) Give a title to let the user know what they have to do. Defaults to Skriv og få alternativer.
disable_filterboolean(optional) If set to true, word highlighting will still be active, but no options will be filtered out. Defaults to false.
disable_highlightingboolean(optional) If set to true, word highlighting will be disabled, but the options will still get filtered. Defaults to false.
disable_reorderboolean(optional) If set to true, reordering of search results will be disabled. Defaults to false.
search_numbersboolean(optional) If set to true and search_in_word_index is not set, the user will be able to more easily search and filter e.g. bank account numbers. Defaults to false.
search_in_word_indexboolean(optional) This gives you the possibility to change the threshold number, which defines from what word on we search "inside words". Defaults to 3.
keep_valueboolean(optional) Use true to not remove the typed value on input blur, if it is invalid. By default, the typed value will disappear / replaced by a selected value from the data list during the input field blur. Defaults to false.
keep_selectionboolean(optional) Use true to not remove selected item on input blur, when the input value is empty. Defaults to false.
keep_value_and_selectionboolean(optional) Like keep_value – but would not reset to the selected value during input field blur. Also, the selected value would still be kept. Defaults to false.
prevent_selectionboolean(optional) If set to true, no permanent selection will be made. Also, the typed value will not disappear on input blur (like keep_value). Defaults to false.
show_clear_buttonboolean(optional) If set to true, a clear button is shown inside the input field. Defaults to false.
iconstring
React.Node
(optional) To be included in the autocomplete input.
icon_sizestring(optional) Change the size of the icon pragmatically.
icon_positionstring(optional) Position of the icon inside the autocomplete. Set to left or right. Defaults to left.
input_iconstring
React.Node
(optional) Same as icon.
triangle_positionstring(optional) Position of icon arrow / triangle the drawer. Set to left or right. Defaults to left.
sizestring(optional) Define the height of the Autocomplete. Can be set to small, default, medium and large. Defaults to default.
drawer_classstring(optional) Define a custom class for the internal drawer-list. This makes it possible more easily customize the drawer-list style with styled-components and the css style method. Defaults to null.
show_submit_buttonboolean(optional) Use true to show a Autocomplete button to toggle the DrawerList. Defaults to false.
align_autocompletestring(optional) Use right to change the options alignment direction. Defaults to left.
no_optionsboolean(optional) Text show in the "no options" item. Defaults to Ingen alternativer.
aria_live_optionsReact.Node(optional) Text read out by screen readers. This way users with screen readers know how many options they got during typing. Defaults to %s alternativer.
show_allboolean(optional) Text that lets a user unravel all the available options. Defaults to Vis alt.
indicator_labelReact.Node(optional) Text show on indicator "options" item. Defaults to Henter data ....
show_options_srstring(optional) Only for screen readers. Title of the button to show the suggestions / options. It is always present and when activating, it opens the DrawerList and sets the focus on it. Defaults to Bla gjennom alternativer.
selected_srstring(optional) Only for screen readers (VoiceOver). The label used to announce the selected item. Defaults to Valgt:.
submit_button_titleReact.Node(optional) Title on submit button. Defaults to Vis alternativer.
submit_button_iconstring
React.Element
(optional) The icon used in the submit button. Defaults to chevron_down.
submit_elementReact.Node(optional) Replace the dropdown / submit button with a custom React element. Defaults to the input SubmitButton import { SubmitButton } from '@dnb/eufemia/components/input/Input'.
openedboolean(optional) If set to true, the Autocomplete will be rendered initially with a visible and accessible data list / options.
open_on_focusboolean(optional) Use true to auto open the list once the user is entering the input field with the keyboard.
stretchboolean(optional) If set to true, then the autocomplete will be 100% in available width.
skip_portalstring(optional) Set to true to disable the React Portal behavior. Defaults to false.
statusstring(optional) Text with a status message. The style defaults to an error message. You can use true to only get the status color, without a message.
status_statestring(optional) Defines the state of the status. Currently, there are two statuses [error, info]. Defaults to error.
status_propsobject(optional) Use an object to define additional FormStatus properties.
globalStatusobject(optional) The configuration used for the target GlobalStatus.
labelReact.Node(optional) Prepends the Form Label component. If no ID is provided, a random ID is created.
label_directionReact.Node(optional) Use label_direction="vertical" to change the label layout direction. Defaults to horizontal.
label_sr_onlyboolean(optional) Use true to make the label only readable by screen readers.
suffixReact.Node(optional) Text describing the content of the Autocomplete more than the label. You can also send in a React component, so it gets wrapped inside the Autocomplete component.
skeletonboolean(optional) If set to true, an overlaying skeleton with animation will be shown.
input_refReact.Ref(optional) Use a React.Ref to get access to the input DOM element.
input_elementstring
React.Element
(optional) Lets you provide a custom React element as the input HTML element.
DrawerListVarious(optional) all DrawerList properties.
Spacestring
object
(optional) Spacing properties like top or bottom are supported.

DrawerList Properties

PropertyTypeDescription
datastring | object | function(required) The data we want to fill the list with. Provide the data as a JSON string, array, or object in the specified data structure. If you don't have to define a value, you can also send in a function which will be called once the user opens the DrawerList.
valuestring
number
(optional) Define a preselected data entry (index) or key inside an array item. Can be a string or integer.
default_valuenumber(optional) Define a startup value or handle a re-render without handling the state during the re-render by yourself. Defaults to null.
triangle_positionstring(optional) Position of the arrow icon/triangle inside the drawer-list. Set to 'left' or 'right'. Defaults to 'left' if not set.
directionstring(optional) Defines the direction of how the drawer-list shows the options list. Can be 'bottom' or 'top'. Defaults to 'auto'.
label_directionstring(optional) The direction of the label. If set to 'horizontal', the label will be positioned horizontally next to the input element. If set to 'vertical', the label will be positioned vertically above the input element.
prevent_selectionboolean(optional) If set to true, the DrawerList will then not make any permanent selection.
focusableboolean(optional) If set to true, the element is then focusable by assertive technologies.
prevent_closeboolean(optional) If set to true, the DrawerList will not close on any events.
keep_openboolean(optional) If set to true, the DrawerList will close on outside clicks, but not on selection.
independent_widthboolean(optional) If set to true, the DrawerList will handle its width and position independently of the parent/mother element.
fixed_positionboolean(optional) If set to true, the DrawerList will be fixed in its scroll position by using CSS position: fixed;.
enable_body_lockboolean(optional) If set to true, the HTML body will get locked from scrolling when the Dropdown is open.
skip_keysearchboolean(optional) If set to true, search items by the first key will be ignored.
ignore_eventsboolean(optional) If set to true, all keyboard and mouse events will be ignored.
align_drawerstring(optional) Use 'right' to change the options alignment direction. Makes only sense to use in combination with prevent_selection or more_menu - or if an independent width is used.
list_classstring(optional) Define an HTML class that will be set on the list, beside dnb-drawer-list__list.
portal_classstring(optional) Define an HTML class that will be set on the DOM portal beside dnb-drawer-list__portal__style. Can be useful to handle e.g. a custom z-index in relation to a header.
scrollableboolean(optional) Defines if the options list should be scrollable (the max-height is set by default to 50vh).
no_scroll_animationboolean(optional) To disable scrolling animation.
no_animationboolean(optional) To disable appear/disappear (show/hide) animation.
skip_portalboolean(optional) To disable the React Portal behavior.
min_heightstring(optional) Defines the minimum height (in rem) of the options list.
max_heightstring(optional) Defines the maximum height (in rem) of the options list.
page_offsetstring(optional) Defines the available scrollable height. If scrolling should not change the height of the drawer-list, then set it to 0 (useful if the DrawerList is used in fixed positions on contrast to a scrollable page content).
observer_elementstring(optional) Set a HTML element, either as a selector or a DOM element. Can be used to send in an element which will be used to make the direction calculation on.
cache_hashstring(optional) Set a cache_hash as a string to enable internal memorizing of the list to enhance rerendering performance. Components like Autocomplete are using this because of the huge data changes due to search and reorder.
wrapper_elementHTMLElement(optional) Has to be an HTML Element, ideally a mother element, used to calculate sizes and distances. Also used for the 'click outside' detection. Clicking on the wrapper_element will not trigger an outside click.
options_renderfunction(optional) Has to be a function, returning the items again. See example. This can be used to add additional options above the actual rendered list.
Spacestring
object
(optional) Spacing properties like top or bottom are supported.

Data structure

// 1. as array
const data = [
// Every data item can, beside "content" - contain what ever
{
// (optional) can be what ever
selected_key: 'key_0',
// (optional) is show instead of "content", once selected
selected_value: 'Item 1 Value',
suffix_value: 'Addition 1',
// Item content as a string, array or React Element
content: 'Item 1 Content',
},
// more items ...
{
selected_key: 'key_1',
content: (
<>
<IconPrimary icon="bell" />
<span className="dnb-typo-bold">Searchable content</span>
</>
),
},
{
selected_key: 'key_2',
selected_value: 'Item 3 Value',
suffix_value: 'Addition 3',
content: (
<Autocomplete.HorizontalItem>
<IconPrimary icon="bell" />
<span className="dnb-typo-bold">Searchable content</span>
</Autocomplete.HorizontalItem>
),
},
{
selected_key: 'key_3',
selected_value: 'Item 4 Value',
suffix_value: 'Addition 4',
content: ['Item 4 Content A', <>Custom Component</>],
},
]
// 2. as object
const data = {
a: 'A',
b: 'B',
}

Translations

More info about translations can be found in the general localization and Eufemia Forms localization docs.

Keynb-NOen-GBen-US
Autocomplete.titleSkriv og velgType and selectType and select
Autocomplete.submit_button_titleVis alternativerShow optionsShow options
Autocomplete.no_optionsIngen alternativerNo optionNo option
Autocomplete.show_allVis altShow everythingShow everything
Autocomplete.show_options_srBla gjennom alternativer, lukk med esc knappenBrowse options, close with esc buttonBrowse options, close with esc button
Autocomplete.aria_live_options%s alternativer%s options%s options
Autocomplete.selected_srValgt:Selected:Selected:
Autocomplete.indicator_labelHenter data ...Getting data ...Getting data ...