Skip to content

Options ​

Options can be set in three ways. Later ones win:

  1. FlowSelect.defaults for every select
  2. data-fs-* attributes, or a JSON object in data-flow-select='{ ... }'
  3. The object passed to new FlowSelect(select, options)

Attribute names are the option names in kebab case with data-fs-: maxItems is data-fs-max-items. "true", "false" and an empty value are read as booleans; numbers are read as numbers.

Appearance ​

OptionAttributeDefaultDescription
variantdata-fs-variant'field''field', 'pill' or 'ghost'. See Variants
sizedata-fs-size'''sm' or 'lg'
checkPositiondata-fs-check-position'start''start', 'end' or 'none'
classNamedata-fs-class-name''Extra classes on the wrapper
maxHeightdata-fs-max-height''Maximum list height, any CSS length

Behaviour ​

OptionAttributeDefaultDescription
searchdata-fs-searchnullnull automatic, true, false, 'inline' or 'dropdown'. See Search
searchThresholddata-fs-search-threshold8Automatic search turns on above this many options
searchPlaceholderdata-fs-search-placeholder'Search...'Placeholder of the dropdown search box
placeholderdata-fs-placeholder''Text when nothing is chosen. Defaults to the <option value=""> label
clearabledata-fs-clearablefalseShows a clear button when a value is chosen
hidePlaceholderOptiondata-fs-hide-placeholder-optionfalseLeaves the <option value=""> row out of the list
closeOnSelectdata-fs-close-on-selectnullnull: single closes, multiple stays open
maxItemsdata-fs-max-items0Multiple: maximum choices, 0 for no limit
hideSelecteddata-fs-hide-selectedfalseMultiple: hides chosen options from the list
createdata-fs-createfalsetrue, or async (label, instance) => item or null. See Creating options
pageSizedata-fs-page-size100Rows rendered at a time in long lists
refreshOndata-fs-refresh-on''Space separated document events that call reload()

Remote data ​

OptionAttributeDefaultDescription
urldata-fs-url''Endpoint. {query} and {page} placeholders, or ?q= and &page= are added
loadnullasync (query, { page, signal }) => items or { items, hasMore }
queryParamdata-fs-query-param'q'Query parameter name
minQueryLengthdata-fs-min-query-length0Characters needed before searching
debouncedata-fs-debounce250Milliseconds to wait after typing
cachedata-fs-cachetrueRemember results per query and page (last 50)
fetchOptionsnullExtra fetch() options such as headers
mapItemnull(serverItem) => item

See Remote data.

Rendering and text ​

OptionDefaultDescription
renderOptionnull(item, { selected }) => Node or HTML string. See Custom rendering
renderValuenull(item) => Node or HTML string
messagessee MessagesTexts and screen reader announcements

Option attributes ​

On each <option>:

AttributeDescription
data-descriptionSecond line, wraps
data-metaSmall muted text under the label
data-badgeSmall rounded tag
data-avatarImage URL, or up to two letters
data-keywordsExtra words to search on
disabled, hidden, selectedNative meaning

Select attributes ​

AttributeDescription
data-flow-selectEnhance automatically. May hold a JSON options object
data-flow-select="manual"Pre-styled, but you create the instance in JavaScript
multiple, required, disabled, name, formNative meaning
aria-label, aria-labelledby, aria-describedbyPassed to the control

Released under the MIT License.