Combobox
Like a text input and a select box had a baby
Includes a Ruby component and corresponding Rails helper
RubyIncludes a Stimulus controller
StimulusExample
- Assetto Corsa
- Automobilista
- Blur
- Burnout Paradise
- Crash Team Racing
- Crazy Taxi
- Daytona USA
- Dirt Rally
- Driver
- Excitebike
- Extreme-G
- F-Zero
- F1 23
- FlatOut
- Forza Horizon
- Gran Turismo
- Hot Wheels Unleashed
- Hydro Thunder
- KartRider
- Mario Kart
- Midnight Club
- MotoGP
- MotorStorm
- Need for Speed
- OutRun
- Pole Position
- Project Cars
- Pure
- Race Driver: Grid
- RalliSport Challenge
- Ridge Racer
- Road Rash
- Rocket League
- Sega Rally Championship
- SnowRunner
- Speed Devils
- Split/Second
- Stuntman
- Super Hang-On
- Super Off Road
- Test Drive Unlimited
- The Crew
- Tourist Trophy
- TrackMania
- V-Rally
- Wave Race
- Wipeout
- Wreckfest
- iRacing
<%= nk_combobox "name", %w[mario_kart need_for_speed] %>
Dependencies
This component adds third-party dependencies:
Form use
To use in forms, it's easiest to use the Form Builder.
For extra convenience use the f.field
method.
<%= nk_form_for :high_score do |f| %>
<%= f.field :game_id,
as: :combobox,
placeholder: "Best game ever",
label: "Game",
description: "In which game did you beat the world record again?",
options: Game.pluck(:name, :id) %>
<% end %>
Options
Combobox expects an array of [label, value]
tuples similar to Rails' options_for_select
.
Eventually I would love to add support for async loading results, like autocomplete search or similar.
Usage
NB: Using via f.field
is recommended.
| ||
---|---|---|
Property | Default | Description |
options | [] |
An array of [label, value] tuples, like [["Mario Kart", "mario_kart"], ["Need for Speed", "need_for_speed"]]
|
placement | nil | Floating UI Placement of the dropdown |
tab_inserts_suggestions | true | @github/combobox-nav Docs |
first_option_selection_mode | "selected" | @github/combobox-nav Docs |
scroll_into_view_options | {block: "nearest", inline: "nearest"} | @github/combobox-nav Docs |
**attrs | HTML attributes for <input> element |