Usage

HTML (Auto-init)

HTML
<select class="fw-select" id="country">
  <option value="US">United States</option>
  <option value="CA">Canada</option>
</select>

<script>
  FormWidgets.autoInit();
</script>

JavaScript Initialization

JavaScript
FormWidgets.init('#country', 'SelectField', {
    placeholder: 'Please choose a country...',
    searchable: true
});

Options

OptionTypeDefaultDescription
iconstring'list'Name of the SVG icon to use from the internal icon set.
placeholderstring'Select an option...'Placeholder text shown when no option is selected.
requiredbooleanfalseMarks the field as required.
searchablebooleanfalseIf true, adds a search input to the dropdown to filter options.
nativeOnMobilebooleantrueIf true, the native browser <select> UI is used on mobile devices for better usability.

Data Attributes

Data AttributeEquivalent OptionExample
data-iconicondata-icon="list"
data-placeholderplaceholderdata-placeholder="Choose..."
data-requiredrequireddata-required="true"
data-searchablesearchabledata-searchable="true"
data-native-on-mobilenativeOnMobiledata-native-on-mobile="false"

Features

Searchable

Quickly find options in long lists with the built-in search filter.

Mobile Friendly

Defaults to the native mobile UI for the best user experience on small screens.

Keyboard Accessible

Full keyboard navigation support for opening, closing, and selecting options.

Themeable

Fully styled with CSS variables to match your application's theme.