Skip to content

Select Filter

A select filter inserts a select box with predefined options that allows user to select one or many options to filter by.

Getting Started

You can create a select filter as so:

go
FilterSelect("jobs")

Options

Unsorted Maps

Go does not provide a built-in data structure for maintaining insertion order into maps.

Iridium has it's own ordered_map collection to solve this issue. This means you're required to use or satisfy our ordered_map struct/interface and pair interface, to populate a list of dropdown items with a particular order. If you don't care about order, you can pass in a simple map[string]string as well.

You can set the options for your search filter as so:

go
FilterSelect("Jobs").
    Options([]collections.Pair[string, string]{
        {"cashier", "Cashier"},
        {"conductor", "Conductor"},
        {"firefighter", "Fire-Fighter"},
    })

UnorderedOptions

If order is no concern in your select's avaliable options, you can use the UnorderedOptions method like so:

go
FilterSelect("Jobs").
    OptionsUnordered(map[string]string{
        "cashier": "Cashier",
        "conductor": "Conductor",
        "firefighter": "Fire-Fighter",
    }}

Placeholder

You can set the placeholder for your select box as so:

go
FilterSelect("Jobs").
    Placeholder("Please select a job to filter by...")

NoResults

You can set the message to appear if no results are found during a search as so:

go
FilterSelect("Jobs").
    NoResults("Looks like no one has that job! Search something else please :)")

Scrollable

You can allow your select options to be scrollable as so:

go
FilterSelect("Jobs").
    Scrollable()

NoScroll

You can make your select options be fully displayed with no scrolling as so:

go
FilterSelect("Jobs").
    NoScroll()

Multiple

You can enable selecting multiple values in your options as so:

go
FilterSelect("Jobs").
    Multiple()

Released under the MIT License.