Select component has two types of selection: single selection (using Radios or Lists) or multiple selection (using Checkboxes or Toggles). This component opens up a Popover for the selection list and action. A filter can also be used for longer lists.
If you need a Dialog for the selection, use the sibling Dialog Select component.
Works well with QField for additional functionality such as a helper, error message placeholder and many others.
Basic Usage
Vue Properties
Supports v-model
which should be the String for single selection and Array for multiple selection.
Vue Property | Type | Description |
---|---|---|
options | Array | (Required) A list of objects to present as the selection’s options. See below for the data format for the array. |
multiple | Boolean | If set to true , multiple selections will be allowed. |
radio | Boolean | If set to true , the selection will be through radios. For single selection only. |
toggle | Boolean | If set to true , the selection options will offer a toggle to select them. |
chips | Boolean | If set to true , the selections will appear as chips (instead of comma separated strings) on the input frame (works for multiple selection only). |
frame-color | String | One from Quasar Color Palette. Useful when color is to be used for Chips alone and you want a different color for the input frame. |
filter | Boolean | If set to true , the selections will offer an input to filter the selection options. |
autofocus-filter | Boolean | Auto-focus on the filter input field (if available) when opening selection. |
filter-placeholder | String | A text to show in the filter input field. Default is “Filter”. |
separator | Boolean | If set to true , the selection options will be separated by a line. |
display-value | String | Overrides text displayed in input frame. See “Working with Display Value” section below. |
clearable | Boolean | If set to true , the component offers the user an actionable icon to remove the current selection. |
Common input frame properties:
Property | Type | Description |
---|---|---|
prefix | String | A text that should be shown before the textfield. |
suffix | String | A text that should be shown after the textfield. |
float-label | String | A text label that will “float” up above the input field, once the input field gets focus. |
stack-label | String | A text label that will be shown above the input field and is static. |
color | String | A color from the Quasar Color Palette. |
inverted | Boolean | Inverted mode. The color is applied to the background instead. |
dark | Boolean | Is QSelect rendered on a dark background? |
align | String | One of ‘left’, ‘center’ or ‘right’ which determines the text align within the textfield. |
disable | Boolean | If set to true , the field is disabled and the user cannot select anything. |
error | Boolean | If set to true , the input field’s colors are changed to show there is an error. |
before | Array of Objects | Icon buttons positioned on the left side of field. |
after | Array of Objects | Icon buttons on the right side of the field. |
Icon buttons
This section refers to before
and after
properties which can add additional buttons as icons to the textfield. Here is the structure of the two properties:
Examples:
Selection Types
You have a number of possible selection types to choose from. They are straight text with optional icons and stamp values, radios, checkboxes, and toggles. Text is default for single selections and checkboxes are default for multiple selections.
Use the radio
prop for single selections. These checkboxes are inserted where the icons would be, so you cannot have icons and checkboxes for multiple selections. If you still want icons with your multiple selections, use the toggle
prop. This would, however, replace the stamp option.
The Options Array Format
Below are examples of the array of options you must use to create the selection options:
Select options object:
More advanced select list object example:
Note
Set “inset” totrue
, instead of an icon, so the label text is properly aligned with the other options that use icons or avatars.
Use an Object for each option like above (notice that it uses some properties from List and List Items components, like “label”, “sublabel”, “stamp”, “icon”, “rightIcon” and so on. Here is the full list of properties that can be used for each option:
Property | Type | Description |
---|---|---|
leftColor | String | Color for left side from Quasar Color Palette. |
icon | String | Icon on the left to use. |
avatar | String | URL pointing to statics for an avatar. |
letter | String | One character String. |
image | String | URL pointing to statics for an image. |
label | String | Main label of the selection. |
sublabel | String | Sub-label of the selection. |
labelLines | String/Number | Number of lines that label can expand to. |
sublabelLines | String/Number | Number of lines that the sublabel can expand to. |
inset | Boolean | Inset Label if no left-side is specified (no icon, avatar, letter or image). |
rightColor | String | Color for right side from Quasar Color Palette. |
rightIcon | String | Icon on the right to use. |
rightAvatar | String | URL pointing to statics for an avatar on right side. |
rightLetter | String | One character String for right side. |
rightImage | String | URL pointing to statics for an image on right side. |
stamp | String | Stamp to use for right side. Example: ‘10 min ago’. |
Working with Display Value
If for some reason you want to have total control over the text in the input frame (replacing the comma delimited option strings), then use display-value
property:
For a more elegant solution (and more efficient too), use a computed property:
Vue Methods
Vue Method | Description |
---|---|
open() | Opens the Popover |
close() | Closes the Popover |
Vue Events
Vue Event | Description |
---|---|
@change(newValue) | Triggered on model value change. |
@focus | Triggered, when the field gets focus. |
@blur | Triggered, when the field loses focus. |
More Examples
Error State
Use the error
prop, to change the color of the component to red:
Disable
Use the disable
prop, to stop access to the field.
Labeling
As with any input, you have two options for labels. Stack and Floating. Unless you wrap it with a QField which has its own label.
Coloring
Use the color
, inverted
and frame-color
props to control the coloring of the component.
Note
The optionalframe-color
prop is useful when using chips as selected values, so the chips stand out from the background color.
Usage Inside of a List
Datetime Range Dialog Select
Last updated: Tue Feb 20 2018
Caught a mistake or want to contribute to the documentation? Suggest an edit on GitHub