js-components-basic-option.md 3.2 KB
Newer Older
E
ester.zhou 已提交
1
# option
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3 4 5
>  **NOTE**
>
>  This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
6

E
ester.zhou 已提交
7
When used as a child component of **[\<select>](../arkui-js/js-components-basic-select.md)**, the **\<option>** component is used to display items in the drop-down list.
Z
zengyawen 已提交
8 9


E
ester.zhou 已提交
10 11
When used as a child component of **[\<menu>](../arkui-js/js-components-basic-menu.md)**, the **\<option>** component is used to display items in the displayed menu.

Z
zengyawen 已提交
12

E
ester.zhou 已提交
13
## Required Permissions
Z
zengyawen 已提交
14 15 16 17

None


E
ester.zhou 已提交
18
## Child Components
Z
zengyawen 已提交
19

E
ester.zhou 已提交
20
Not supported
Z
zengyawen 已提交
21 22


E
ester.zhou 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
## Attributes

In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.

| Name      | Type     | Default Value | Mandatory  | Description                                      |
| -------- | ------- | ---- | ---- | ---------------------------------------- |
| selected | boolean | -    | No   | Whether the option is the default option in the drop-down list. This attribute is available only when the parent component is **\<select>**.         |
| value    | string  | -    | Yes   | Value of the option, which is used as the return value of the **selected** event of the **\<select>** or **\<menu>** parent component.<br>The value to be displayed on the UI must be put between the start and end tags, for example,<br>**\<option value="10">October\</option>**. |
| icon     | string  | -    | No   | Icon resource path. This icon is displayed before the option text. The supported icon formats are JPG, PNG, and SVG.    |


## Styles

The following styles are supported.

| Name             | Type                        | Default Value       | Mandatory  | Description                                      |
| --------------- | -------------------------- | ---------- | ---- | ---------------------------------------- |
| color           | &lt;color&gt;              | \#e6000000 | No   | Font color of the option.                               |
| font-size       | &lt;length&gt;             | 16px       | No   | Font size of the option.                               |
| allow-scale     | boolean                    | true       | No   | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.|
| font-weight     | number \| string | normal     | No   | Font weight of the option. For details, see **font-weight** of the [**\<text>**](../arkui-js/js-components-basic-text.md#styles) component. |
| text-decoration | string                     | none       | No   | Text modification of an option. For details, see **text-decoration** of the [**\<text>**](../arkui-js/js-components-basic-text.md#styles) component. |
| font-family     | string                     | sans-serif | No   | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](../arkui-js/js-components-common-customizing-font.md) is used for the text.|


## Events

Not supported


## Methods

Not supported

Z
zengyawen 已提交
57

E
ester.zhou 已提交
58
## Example
Z
zengyawen 已提交
59

E
ester.zhou 已提交
60
For details, see [Example in menu](../arkui-js/js-components-basic-menu.md#example).