Skip to content

Properties

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

PropertiesDescription
mode(optional) if set to async, it prevents showing the "no options" message during typing / filtering. Defaults to sync.
input_value(optional) lets you define a custom input value.
placeholder or title(optional) use this to define the pre-filled placeholder text in the input. Defaults to title="Skriv og velg".
disable_filter(optional) if set to true, word highlighting will still be active, but no options will be filtered out. Defaults to false.
disable_highlighting(optional) if set to true, word highlighting will be disabled, but the options will still get filtered. Defaults to false.
disable_reorder(optional) if set to true, reordering of search results will be disabled. Defaults to false.
search_numbers(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_index(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_value(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.
keep_value_and_selection(optional) like keep_value – but would not reset to the selected value during input field blur. Also, the selected value would still be kept.
prevent_selection(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_button(optional) if set to true, a clear button is shown inside the input field. Defaults to false.
icon(optional) to be included in the autocomplete input.
icon_size(optional) change the size of the icon pragmatically.
icon_position(optional) position of the icon inside the autocomplete. Set to left or right. Defaults to left.
input_icon(optional) same as icon.
triangle_position(optional) position of icon arrow / triangle the drawer. Set to left or right. Defaults to left.
size(optional) define the height of the Autocomplete. Can be set to small, default, medium and large. Defaults to default.
drawer_class(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_button(optional) use true to show a Autocomplete button to toggle the DrawerList. Defaults to false.
title(optional) give a title to let the user know what they have to do. Defaults to Skriv og få alternativer.
align_autocomplete(optional) use right to change the options alignment direction. Defaults to left.
no_options(optional) text show in the "no options" item. Defaults to Ingen alternativer.
aria_live_options(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_all(optional) text that lets a user unravel all the available options. Defaults to Vis alt.
indicator_label(optional) text show on indicator "options" item. Defaults to Henter data ....
show_options_sr(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_sr(optional) only for screen readers (VocieOver). The label used to announce the selected item. Defaults to Valgt:.
submit_button_title(optional) title on submit button. Defaults to Vis alternativer.
submit_button_icon(optional) the icon used in the submit button. Defaults to chevron_down.
submit_element(optional) replace the dropdown / submit button with a custom React element. Defaults to the input SubmitButton import { SubmitButton } from '@dnb/eufemia/components/input/Input'.
opened(optional) if set to true, the Autocomplete will be rendered initially with a visible and accessible data list / options.
open_on_focus(optional) use true to auto open the list once the user is entering the input field with the keyboard.
stretch(optional) if set to true, then the autocomplete will be 100% in available width.
skip_portal(optional) set to true to disable the React Portal behavior. Defaults to false.
status(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_state(optional) defines the state of the status. Currently, there are two statuses [error, info]. Defaults to error.
status_props(optional) use an object to define additional FormStatus properties.
global_status_id(optional) the status_id used for the target GlobalStatus.
label(optional) prepends the Form Label component. If no ID is provided, a random ID is created.
label_direction(optional) use label_direction="vertical" to change the label layout direction. Defaults to horizontal.
label_sr_only(optional) use true to make the label only readable by screen readers.
suffix(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.
skeleton(optional) if set to true, an overlaying skeleton with animation will be shown.
input_ref(optional) use a React.Ref to get access to the input DOM element.
input_element(optional) lets you provide a custom React element as the input HTML element.
DrawerList(optional) all DrawerList properties.
Space(optional) spacing properties like top or bottom are supported.

DrawerList Properties

PropertiesDescription
data or children(required) the data we want to fill the list with. Provide the data as a JSON string, array or object in these 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.
value(optional) should either be an index (integer) of the data array or a key (NB: should not start with a number) – defined by selected_key inside an array item. If data is an object, use the object key (string) as the value to define the selected item. Can be a string or integer. Defaults to null and the title property will be shown.
NB: In case the DrawerList will be re-rendered, this value will be used again. Use default_value instead.
default_value(optional) if you want to define only a startup value (integer) or have to handle a re-render without handling the state during the re-render by yourself, then using default_value is a good choice. Defaults to null.
triangle_position(optional) position of arrow icon/triangle inside the drawer-list. Set to left or right. Defaults to left if not set.
direction(optional) defines the direction of how the drawer-list shows the options list. Can be bottom or top. Defaults to auto.
prevent_selection(optional) If set to true, the DrawerList will then not make any permanent selection. Defaults to false.
focusable(optional) If set to true, the element is then focusable by assertive technologies.
prevent_close(optional) If set to true, the DrawerList will not close on any events. Defaults to false.
keep_open(optional) If set to true, the DrawerList will close on outside clicks, but not on selection. Defaults to false.
independent_width(optional) If set to true, the DrawerList will handle it's width and position handling independent to the parent/mother element. Defaults to false.
fixed_position(optional) If set to true, the DrawerList will be fixed in it's scroll position by using CSS position: fixed;. Defaults to false.
enable_body_lock(optional) If set to true, the HTML body will get locked from scrolling when the Dropdown is open. Defaults to false.
skip_keysearch(optional) If set to true, search items by the first key will be ignored. Defaults to false.
ignore_events(optional) If set to true, all keyboard and mouse events will be ignored. Defaults to false.
align_drawer(optional) use right to change the options alignment direction. Makes only sense to use in combination with prevent_selection or more_menu - or if a independent width is used. Defaults to left.
list_class(optional) define a HTML class that will be set on the list, beside dnb-drawer-list__list.
portal_class(optional) define a 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.
scrollable(optional) defines if the options list should be scrollable (the max-height is set by default to 50vh). Defaults to true.
no_scroll_animation(optional) to disable scrolling animation. Defaults to false.
no_animation(optional) to disable appear/disappear (show/hide) animation. Defaults to false.
skip_portal(optional) to disable the React Portal behavior. Defaults to false.
min_height(optional) defines if the minimum height (in rem) of the options list. Defaults to 10rem.
max_height(optional) defines if the maximum height (in rem) of the options list. Defaults to null, as this is set automatically by default.
page_offset(optional) defines if the available scrollable height. If scrolling not should 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). Defaults to window.pageYOffset.
observer_element(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_hash(optional) set a cache_hash as a string to enable internal memorizing of the list to enhance rerendering performance. Components like Autocomplete is using this because of the huge data changes due to search and reorder. Defaults to null.
wrapper_element(optional) has to be a HTML Element, ideal a mother element, used to calculate sizes and distances. Also used for the "click outside" detection. Clicking on the wrapper_element will not be anymore triggered as an outside click.
options_render(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.
Space(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',
}