We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
quickApp ReferencesQuick AppElementsoption

option

Overview

Displays the items in the drop-down list box. The option element is subordinate to the select element.

Application Scope

Expand

Item

Description

Applicable devices

Mobile phones, tablets, and telematics devices

Applicable regions

Global

Subelements

None

Attributes

In addition to general attributes, the attributes listed in the following table are supported.

Expand

Attribute

Type

Default Value

Mandatory

Description

selected

boolean

-

No

Indicates whether the selected item is the default item in the drop-down list box.

value

string

-

Yes

Options in the drop-down list box. Put them between the tags, for example, <option value="volvo">Volvo XC90</option>.

Styles

In addition to common styles, the styles listed in the following table are supported.

NOTICE

The width and height styles cannot be customized for options. That is, their settings are invalid. The option subelement has the same width as the select element and has a fixed height.

Expand

Style

Type

Default Value

Mandatory

Description

color

color

0x8a000000

No

Font color.

font-size

number

30px

No

Font size.

font-weight

lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | normal | bold | bolder

normal

No

Font weight. The default value is normal.

text-decoration

underline | line-through | none

none

No

Decorations added to text.

font-family (1030+)

string

-

No

Font of strings in the element. Android's default fonts normal, sans-serif, serif, and monospace are supported (only for English strings).

To customize fonts, please refer to font-face Style.

Events

None

Sample Code

Collapse
Word wrap
Dark theme
Copy code
  1. <template>
  2. <div class="container container1">
  3. <div class="page-title-wrap">
  4. <text class="page-title">{{componentName}}</text>
  5. </div>
  6. <div class="item-container">
  7. <text style="margin-bottom: 50px">Nanjing Attractions</text>
  8. <select class="select" onchange="changeValue">
  9. <option class="option" value="item1">Confucius Temple</option>
  10. <option class="optionrgb" value="item2" selected="true">presidential palace</option>
  11. <option class="optionrgba" value="item3">Old door east</option>
  12. <option class="optionhsl" value="item4">Da Bao En Temple</option>
  13. <option class="optionhsla" value="item5">Zhonghuamen</option>
  14. </select>
  15. </div>
  16. <div class="item-container">
  17. <text style="margin-bottom: 50px">font-family</text>
  18. <select class="select font-family2" onchange="changeValue">
  19. <option class="option font-family1" value="item1">font-family is sans-serif</option>
  20. <option class="option font-family2" value="item2" selected="true">font-family is serif</option>
  21. <option class="option font-family3" value="item3">font-family is monospace</option>
  22. </select>
  23. </div>
  24. </div>
  25. </template>
  26. <style>
  27. .container {
  28. flex: 1;
  29. flex-direction: column;
  30. }
  31. .page-title-wrap {
  32. padding-top: 50px;
  33. padding-bottom: 80px;
  34. justify-content: center;
  35. }
  36. .page-title {
  37. padding-top: 30px;
  38. padding-bottom: 30px;
  39. padding-left: 40px;
  40. padding-right: 40px;
  41. border-color: #bbbbbb;
  42. color: #bbbbbb;
  43. border-bottom-width: 2px;
  44. }
  45. .item-container {
  46. margin-bottom: 50px;
  47. margin-right: 60px;
  48. margin-left: 60px;
  49. flex-direction: column;
  50. }
  51. .select {
  52. margin-left: 30px;
  53. margin-right: 30px;
  54. align-items: flex-start;
  55. border-color: #007DFF;
  56. border-width: 1px;
  57. }
  58. .container1 {
  59. align-items: center;
  60. }
  61. .option {
  62. color: #007DFF;
  63. font-size: 30px;
  64. font-weight: bold;
  65. text-decoration: line-through;
  66. }
  67. .optionrgb {
  68. color: rgb(207, 18, 49);
  69. font-size: 30px;
  70. font-weight: bold;
  71. text-decoration: line-through;
  72. }
  73. .optionrgba {
  74. color: rgba(86, 206, 38, 0.452);
  75. font-size: 30px;
  76. font-weight: bold;
  77. text-decoration: line-through;
  78. }
  79. .optionhsl {
  80. color: hsl(180, 100%, 80%);
  81. font-size: 30px;
  82. font-weight: bold;
  83. text-decoration: line-through;
  84. }
  85. .optionhsla {
  86. color: hsla(10, 90%, 60%, 0.9);
  87. font-size: 30px;
  88. font-weight: bold;
  89. text-decoration: line-through;
  90. }
  91. .font-family1 {
  92. font-family: sans-serif;
  93. }
  94. .font-family2 {
  95. font-family: serif;
  96. }
  97. .font-family3 {
  98. font-family: monospace;
  99. }
  100. </style>
  101. <script>
  102. import prompt from '@system.prompt'
  103. export default {
  104. data: {
  105. componentName: 'select'
  106. },
  107. onInit() {
  108. this.$page.setTitleBar({ text: 'option' })
  109. },
  110. changeValue(e) {
  111. prompt.showToast({
  112. message: `[${e.newValue}] selected`,
  113. duration: 2000,
  114. gravity: 'center'
  115. })
  116. }
  117. }
  118. </script>

The following figure shows the final effect.

Version Change History

Expand

Version

Date

Description

1030

2018-10-31

  • Added the font-family style. Default fonts normal, sans-serif, serif, and monospace are supported.
  • Added 500, 600, 700, 800, 900, and bolder for the font-weight style. Only bolder among them will bold strings.
Search in References
Enter a keyword.