UXP
v2.0.0
v2.0.0
  • Introduction
    • Welcome
    • Understanding the Portal
    • Getting Started
  • Releases
  • Interface Types
    • Widgets
  • Interface Guidelines
    • Lists
  • Interacting with Lucy
    • Real-Time Communication
  • Interface Guidelines
  • Custom Styles and CSS
  • Publishing your UIs
    • Bundles
  • lucy-xp
  • Components
    • AsyncButton
    • AutoCompleteInput
    • BarChartLoader
    • Button
    • CRUDComponent
    • CalendarComponent
    • Checkbox
    • ColorPallet
    • ColorPicker
    • ConfirmButton
    • DataGrid
    • DataList
    • DataTable
    • DatePicker
    • DateRangePicker
    • DateTimePicker
    • DefaultLoader
    • DonutChartLoader
    • DropDownButton
    • DynamicForm
    • DynamicSelect
    • FileInput
    • FilterPanel
    • FormFeedback
    • FormField
    • GaugeLoader
    • HeatmapChartLoader
    • HorizontalScrollList
    • IconButton
    • Input
    • ItemCard
    • ItemListCard
    • Label
    • LinkButtonWidget
    • LinkWidgetContainer
    • Loading
    • LoadingSpinner
    • LocalizationForm
    • LocalizationFormModal
    • MapComponent
    • Modal
    • ModalWizard
    • MultiSelect
    • NotificationBlock
    • PieChartComponent
    • Popover
    • PortalContainer
    • ProfileImage
    • RadialGauge
    • SampleDataLabel
    • SearchBox
    • Select
    • SideBar
    • SpaceworxDescriptionTag
    • TabComponent
    • TableComponent
    • TextArea
    • ThemeChanger
    • TimePicker
    • TimeRangePicker
    • TitleBar
    • ToggleFilter
    • Tooltip
    • TreeViewSelectInput
    • TrendChartComponent
    • UserProfile
    • WidgetContainerBlock
    • WidgetWrapper
    • Wizard
  • Hooks
    • useAlert
    • useDebounce
    • useEffectWithPolling
    • useEventSubscriber
    • useFields
    • useMessageBus
    • useResizeEffect
    • useToast
    • useUpdateWidgetProps
  • Types
    • ActionResponse
    • CRUDComponentInstanceProps
    • CRUDComponentProps
    • Column
    • DynamicFormFieldProps
    • DynamicFormProps
    • ExtendedFormProps
    • FieldsHook
    • FormProps
    • FormSectionProps
    • FormValue
    • IAlertResult
    • IAnimation
    • IAutoCompleteInputInstanceProps
    • IButtonSize
    • IButtonType
    • IBuyOnSpaceworxButtonProps
    • ICalendarComponentProps
    • ICallback
    • ICheckboxInstanceProps
    • ICheckboxType
    • ICircleBound
    • IColorPalletProps
    • IColorPickerPosition
    • IColorPickerProps
    • IColorTypes
    • IContentFunction
    • IDataFunction
    • IDataItem
    • IDataTableColumn
    • IDatePickerProps
    • IDateRangePickerProps
    • IDateTimePickerProps
    • IDivIconInterface
    • IDropDownButtonPosition
    • IDropDownButtonProps
    • IDynamicSelectDataFunction
    • IEventDispatcher
    • IEventSubscriber
    • IFileInputInstanceProps
    • IFileInputProps
    • IGaugeProps
    • IHeatmapConfiguration
    • IHeatmapPoint
    • IInputInstanceProps
    • IInputType
    • ILanguage
    • ILocalisationFormModalInstanceProps
    • ILocalisationFormModalProps
    • ILocalisationFormProps
    • IMarker
    • IMessage
    • IModalWizardProps
    • IModalWizardStep
    • IModalWizardStepProps
    • IMultiSelectProps
    • IPolygonBound
    • IPopoverPosition
    • IPopoverProps
    • IPortalContainerProps
    • IPosition
    • IPreviewDetails
    • IProfileProps
    • IRegion
    • IRemove
    • IRenderMarkerPopup
    • IRenderMarkerTooltip
    • ISampleDataLabelProps
    • ISearchBoxInstanceProps
    • ISelectProps
    • ISidebarProps
    • ISize
    • ISpaceworxDescriptionTagProps
    • IStaticImage
    • ITextAreaInstanceProps
    • IThemeChangerProps
    • ITitleFunc
    • IToast
    • IToastResult
    • IToggleOption
    • ITooltipPosition
    • ITooltipProps
    • IUseEffectWithPolling
    • IUseUpdateWidgetProps
    • IWidgetContainerBlockProps
    • IWidgetPreloaderLoaderProps
    • IWidgetWrapperProps
    • IWizardStep
    • IWizardStepProps
    • ListProps
    • MessageBusHook
    • PaginationProps
    • RenderCustomFormView
    • ResizeEffectHook
    • TabComponentProps
    • TabComponentStyles
    • TableComponentProps
    • ToastHook
    • TreeViewSelectInputInstanceProps
    • TreeViewSelectInputProps
    • regionType
Powered by GitBook
On this page
  • Installation
  • Examples
  • Properties
  • options
  • labelField
  • valueField
  • iconField
  • selected
  • onChange
  • placeholder
  • className
  • isValid
  • showEndOfContent
  • renderOption
  • addNewValues
  • dropdownClassname
  • spacingMode
  • onClear
  • renderCustomDropdownContent
  • renderPlaceholder
  • dropdownMinWidth
  • dropdownMinHeight
  1. Components

Select

A select control to select one item from a list of multiple items

Installation

import {Select} from 'uxp/components';

Examples

// options
 let [selectedOption, setSelectedOption] = React.useState<string>(null)
 let options = [
     {label: "Sri Lanka", value: "SL"},
     {label: "India", value: "IN"},
     {label: "United State", value: "US"},
 ]

 <Select
     options={options}
     selected={selectedOption}
     onChange={(newValue, option) => {
         setSelectedOption(value)
     }}
 />
// options
 let [selectedOption, setSelectedOption] = React.useState<string>(null)
 let options = [
     {name: "Sri Lanka", code: "SL"},
     {name: "India", code: "IN"},
     {name: "United State", code: "US"},
 ]

 <Select
     options={options}
     labelField="name"
     valueField="code"
     selected={selectedOption}
     onChange={(newValue, option) => {
         setSelectedOption(value)
     }}
 />

Properties

Name
Type
Description

options

IOption[] | any[]

List of items to select from. Each option has a label which is displayed and a value which is what we actually select. also you can pass any object as options, then specify the labelField, valueField props

labelField

string

Name of the field you want to display as label If not given default(label) will be used

valueField

string

Name of the field you want to return as value If not given default(value) will be used

iconField

string

Name if the field to use as icon if a value is passed icon will be displayed.

selected

string

The currently selected value

onChange

(value: string, option?: IOption | any) => void

Gets called whenever the selection changes. The value parameter has the newly selected value option parameter has the complete option/ object that you passed

placeholder

string

Text to show when no value is selected

className

string

Any extra css classes to add to the component

isValid

boolean

Set this to false to indicate the field doesn't have a valid value

showEndOfContent

boolean

show hide end of content message

renderOption

(item: any, key: number) => JSX.Element

A function that will be responsible for rendering each individual option of the list.

addNewValues

{ enable: boolean, title: string, loadingTitle: string, onAddNewValue?: (value: string) => Promise }

Option to add a new value if not available. You can enable this option and handle how you want to save the new item

dropdownClassname

string

Option to add a classname for the dropdown

spacingMode

SpacingMode

Spacing mode

onClear

() => void

Option to unselect

renderCustomDropdownContent

(closeDropdown: () => void) => React.ReactNode

This will replace the content in the dropdown. If this is enabled, above options (value, onChange , etc) will not work. You have to handle everything You will need to handle the value and onChange options. and once you select an option, to close the dropdown, call the closeDropdown function

renderPlaceholder

{ /** * render input as a pill * work with default select dropdown / renderAsPill?: { minWidth?: number, maxWidth?: number }, /* * for custom renders */ renderCustomPill?: (onClear: () => void) => React.ReactNode }

Option to custom render the placeholder

dropdownMinWidth

number

dropdownMinHeight

number

options


List of items to select from. Each option has a label which is displayed and a value which is what we actually select. also you can pass any object as options, then specify the labelField, valueField props

type

IOption[] | any[]

labelField


Name of the field you want to display as label If not given default(label) will be used

type

string

valueField


Name of the field you want to return as value If not given default(value) will be used

type

string

iconField


Name if the field to use as icon if a value is passed icon will be displayed.

type

string

selected


The currently selected value

type

string

onChange


Gets called whenever the selection changes. The value parameter has the newly selected value option parameter has the complete option/ object that you passed

type

(value: string, option?: IOption | any) => void

placeholder


Text to show when no value is selected

type

string

className


Any extra css classes to add to the component

type

string

isValid


Set this to false to indicate the field doesn't have a valid value

type

boolean

showEndOfContent


show hide end of content message

type

boolean

renderOption


A function that will be responsible for rendering each individual option of the list.

type

(item: any, key: number) => JSX.Element

renderItem={(option,key)=><div>{option.label}</div>}
renderItem={(option,key)=><ItemCard data={item} titleField='label' />}

addNewValues


Option to add a new value if not available. You can enable this option and handle how you want to save the new item

type

{ enable: boolean, title: string, loadingTitle: string, onAddNewValue?: (value: string) => Promise }

dropdownClassname


Option to add a classname for the dropdown

type

string

spacingMode


Spacing mode

type

SpacingMode

onClear


Option to unselect

type

() => void

renderCustomDropdownContent


This will replace the content in the dropdown. If this is enabled, above options (value, onChange , etc) will not work. You have to handle everything You will need to handle the value and onChange options. and once you select an option, to close the dropdown, call the closeDropdown function

type

(closeDropdown: () => void) => React.ReactNode

renderPlaceholder


Option to custom render the placeholder

type

{ /** * render input as a pill * work with default select dropdown / renderAsPill?: { minWidth?: number, maxWidth?: number }, /* * for custom renders */ renderCustomPill?: (onClear: () => void) => React.ReactNode }

dropdownMinWidth


type

number

dropdownMinHeight


type

number

PreviousSearchBoxNextSideBar

Last updated 3 months ago