No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Autocomplete

An autocomplete is a normal text input enhanced by a panel of suggested options.

usage
import { Autocomplete, Item, Section } from "@sharegate/orbit-ui";
sources
Github

Usage

Default

A default autocomplete

Editable example

Sections

An autocomplete items can be group by sections.

Editable example

Item icon

An autocomplete item can have icons.

Editable example

Item end icon

An autocomplete item can have non standard end icons can be provided to handle special cases like displaying a list of icons. However, think twice before adding end icons, start icons should be your go to.

Editable example

Item description

An autocomplete item can have a description.

Editable example

A description can be paired with an icon.

Editable example

A description can be paired with an avatar.

Editable example

Trigger icon

An autocomplete trigger can have an icon.

Editable example

Disabled

Editable example

Readonly

Editable example

Fluid

An autocomplete can take the width of it's container.

Editable example

Validation

An autocomplete can display a validation state to communicate to the user whether the current value is valid or invalid. Implement your own validation logic in your app and pass either "valid" or "invalid" to the input via the validationState prop.

The example below illustrates how one would validate that a specific value have been selected.

Editable example

Form

An autocomplete can be part of a form. To submit the value of a select, make sure you specify the name property.

Editable example

Dynamic items

An autocomplete items can be rendered dynamically.

Editable example

Remote items

An autocomplete items can be fetch from a remote source.

We provide an utility hook called useAsyncSearch which accept an async function responsible of fetching the data. You could roll your own utility hook as long as it returns a loading indicator and provide a function to handle search requests.

In most cases, you should pass the signal arg to your fetch request.

Editable example

An autocomplete search strategy can be customized by providing an onSearch handler.

Editable example

Controlled

The selectedKey and open state can be handled in controlled mode.

Editable example

API

Autocomplete

usage
import { Autocomplete } from "@sharegate/orbit-ui";
NameDescriptionDefault
align
The horizontal alignment of the popup relative to the trigger.
"end""start"
-
allowFlip
Whether or not the popup can flip when it will overflow it's boundary area.
falsetrue
-
allowPreventOverflow
Whether or not the popup position can change to prevent it from being cut off so that it stays visible within its boundary area.
falsetrue
-
autoFocus
Whether or not the input should autoFocus on render.
numberfalsetrue
-
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
clearOnSelect
Whether or not the query should be cleared when a result is selected.
falsetrue
-
defaultOpen
The initial value of open when in auto controlled mode.
falsetrue
-
defaultValue
The default value of value when uncontrolled.
string
-
direction
The direction the open will open relative to the trigger.
"bottom""top"
-
fluid
Whether or not the autocomplete take up the width of its container.
false | true | ResponsiveValue<boolean>
-
icon
A trigger icon.
ReactElement<any, string | JSXElementConstructor<any>>
-
loading
Whether or not the autocomplete should display a loading state.
falsetrue
-
minCharacters
Minimum characters to query for results.
number
-
noResultsMessage
Message to display when there are no results matching the query.
string
-
onOpenChange
Called when the open state change.
(event: SyntheticEvent<Element, Event>, isOpen: boolean) => void
eventReact's original event.
isOpenIndicate if the popup is visible.
-
onSearch
Called when the input query change and new search results are expected.
(event: SyntheticEvent<Element, Event>, query: string) => void
eventReact's original event.
queryThe search query.
-
onSelectionChange
Called when the autocomplete value change.
(event: SyntheticEvent<Element, Event>, selection: { key: string; value: string; }) => void
eventReact's original event.
selectionThe new selection.
-
open
Whether or not to show the popup.
falsetrue
-
overlayProps
Additional props to render on the menu of options.
Partial<Omit<OmitInternalProps<InnerOverlayProps, never>, "ref"> & RefAttributes<any>>
-
validationState
Whether or not the input should display as "valid" or "invalid".
"valid""invalid"
-
value
A controlled autocomplete value.
string
-
wrapperProps
Additional props to render on the wrapper element.
Partial<OmitInternalProps<InnerBoxProps, never> & RefAttributes<any>>
-
zIndex
The z-index of the menu.
number
-

Item

usage
import { Item } from "@sharegate/orbit-ui";
slots
"icon", "avatar", "text", "description", "end-icon"
NameDescriptionDefault
children
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
key
A unique key to identify the item.
string
-

Section

usage
import { Section } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-