# \ Development The **\** component supports common, date, time, data and time, and multi-column text selectors. For details, see [picker](../reference/arkui-js/js-components-basic-picker.md). ## Creating a \ Component Create a **\** component in the .hml file under **pages/index**. ```html
picker
``` ```css /* xxx.css */ .container { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; background-color: #F1F3F5; } ``` ![en-us_image_0000001223287716](figures/en-us_image_0000001223287716.gif) ## Setting the Picker Type Set the **type** attribute of the **\** component. For example, set it to **date**. ```html
``` ```css /* xxx.css */ .container { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; background-color: #F1F3F5; } .pickertext{ margin-bottom: 30px; } ``` ```js // xxx.js export default { data: { rangetext:['15', "20", "25"], textvalue:'Select text', datevalue:'Select date', } } ``` ![en-us_image_0000001267647893](figures/en-us_image_0000001267647893.gif) > **NOTE** > > When setting the value range of a common selector, you must use the data binding mode. ## Setting the Time Format Set the **hours** attribute to specify the time format used by the time picker. Available values include **12** and **24**, indicating the 12-hour format and 24-hour format, respectively. ```html
``` ```css /* xxx.css */ .container { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; background-color: #F1F3F5; } .pickertime { margin-bottom:50px; width: 300px; height: 50px; } ``` ![en-us_image_0000001222807808](figures/en-us_image_0000001222807808.gif) > **NOTE** > - When **hours** is set to **12**, the time is displayed in 12-hour format and distinguished by a.m. and p.m. > > - When **hours** is set to **24**, the time is displayed in 24-hour format. ## Adding Response Events Add the **change** event to confirm selection and the **cancel** event to cancel selection. ```html
``` ```css /* xxx.css */ .container { width: 100%; height: 100%; flex-direction: column; justify-content: center; align-items: center; background-color: #F1F3F5; } .pickermuitl { margin-bottom:20px; width: 600px; height: 50px; font-size: 25px; letter-spacing:15px; } ``` ```js // xxx.js import promptAction from '@ohos.promptAction'; export default { data: { multitext:[["a", "b", "c"], ["e", "f", "g"], ["h", "i"]], multitextvalue:'Select multi-line text', multitextselect:[0,0,0], }, multitextonchange(e) { this.multitextvalue=e.newValue; promptAction.showToast({ message:"Multi-column text changed to:" + e.newValue }) }, multitextoncancel() { promptAction.showToast({ message:"multitextoncancel" }) }, } ``` ![en-us_image_0000001223127748](figures/en-us_image_0000001223127748.gif) ## Example Scenario Implement a health check-in application by using the **\** component. ```html
Health check-in
Office:
Office hours:
Having fever or cold symptoms
Close contact with someone with COVID-19
``` ```css /* xxx.css */ .doc-page { flex-direction: column; background-color: #F1F3F5; } .title { margin-top: 30px; margin-bottom: 30px; margin-left: 50px; font-weight: bold; color: #0000ff; font-size: 38px; } .out-container { flex-direction: column; align-items: center; } .pick { width: 80%; height: 76px; border: 1px solid #0000ff; border-radius: 20px; padding-left: 12px; } .txt { width: 80%; font-size: 18px; text-align: left; margin-bottom: 12px; margin-left: 12px; } .dvd { margin-top: 30px; margin-bottom: 30px; margin-left: 80px; margin-right: 80px; color: #6495ED; stroke-width: 6px; } ``` ```js // xxx.js import promptAction from '@ohos.promptAction' export default { data: { yorn1:'No', yorn2:'No', pos:'Home', yesno:['Yes', 'No'], posarr:['Home', 'Company'], datevalue:'Select time', datetimeselect:'2012-5-6-11-25', dateselect:'2021-9-17', showbuild:true }, onInit() { }, isFever(e) { this.yorn1 = e.newValue }, isTouch(e) { this.yorn2 = e.newValue }, setPos(e) { this.pos = e.newValue if (e.newValue === 'Non-research center') { this.showbuild = false } else { this.showbuild = true } }, setbuild(e) { this.build = e.newValue }, dateonchange(e) { e.month=e.month+1; this.datevalue = e.year + "-" + e.month + "-" + e.day; promptAction.showToast({ message:"date:"+e.year+"-"+e.month+"-"+e.day }) }, showtoast() { promptAction.showToast({ message: 'Submitted.', duration: 2000, gravity: 'center' }) } } ``` ![en-us_image_0000001267887877](figures/en-us_image_0000001267887877.gif)