A Picker displays one or more columns with options for users to choose from.
<ion-picker>
<ion-picker-column value="javascript">
<ion-picker-column-option value="" disabled="true">--</ion-picker-column-option>
<ion-picker-column-option value="javascript">Javascript</ion-picker-column-option>
<ion-picker-column-option value="typescript">Typescript</ion-picker-column-option>
<ion-picker-column-option value="rust">Rust</ion-picker-column-option>
<ion-picker-column-option value="c#">C#</ion-picker-column-option>
</ion-picker-column>
</ion-picker>Prefix & Suffix Content
Use the prefix and suffix slots to add additional content to the picker.
<ion-picker>
<ion-picker-column [value]="1">
<div slot="prefix">$</div>
<ion-picker-column-option value="" disabled="true">--</ion-picker-column-option>
<ion-picker-column-option [value]="1">1</ion-picker-column-option>
<ion-picker-column-option [value]="2">2</ion-picker-column-option>
<ion-picker-column-option [value]="3">3</ion-picker-column-option>
<ion-picker-column-option [value]="4">4</ion-picker-column-option>
<ion-picker-column-option [value]="5">5</ion-picker-column-option>
<div slot="suffix">USD</div>
</ion-picker-column>
</ion-picker>Theming
CSS Variables
The picker highlight and fade can be customized using CSS variables on ion-picker. Developers can customize the individual appearance of ion-picker-column-options by targeting them directly and using host level styling.
<ion-picker>
<ion-picker-column value="red">
<ion-picker-column-option value="" disabled="true">--</ion-picker-column-option>
<ion-picker-column-option value="red">Red</ion-picker-column-option>
<ion-picker-column-option value="blue">Blue</ion-picker-column-option>
<ion-picker-column-option value="green">Green</ion-picker-column-option>
</ion-picker-column>
</ion-picker>Picker in Modal
Pickers can be displayed inside of overlays, such as ion-modal to create a picker experience with confirmation or cancellation buttons.
<ion-button id="open-modal">Open modal</ion-button>
<ion-modal #modal trigger="open-modal" [isOpen]="true" (didDismiss)="onDidDismiss($event)">
<ng-template>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button (click)="modal.dismiss(null, 'cancel')">Cancel</ion-button>
</ion-buttons>
<ion-buttons slot="end">
<ion-button (click)="modal.dismiss(currentValue, 'confirm')">Done</ion-button>
</ion-buttons>
</ion-toolbar>
<ion-picker>
<ion-picker-column [value]="currentValue" (ionChange)="onIonChange($event)">
<ion-picker-column-option value="" disabled="true">--</ion-picker-column-option>
<ion-picker-column-option value="javascript">Javascript</ion-picker-column-option>
<ion-picker-column-option value="typescript">Typescript</ion-picker-column-option>
<ion-picker-column-option value="rust">Rust</ion-picker-column-option>
<ion-picker-column-option value="c#">C#</ion-picker-column-option>
</ion-picker-column>
</ion-picker>
</ng-template>
</ion-modal>Accessibility
Screen Readers
Picker supports navigation using a screen reader by implementing the slider role on each Picker Column. The following gestures can be used to navigate the Picker.
| Gesture | Function |
|---|---|
| Swipe Left | Move focus to the previous Picker Column. |
| Swipe Right | Move focus to the next Picker Column. |
| Swipe Up | Select the next option in the Picker Column. |
| Swipe Down | Select the previous option in the Picker Column. |
| Double Tap and Slide Up/Down | Adjust the selected option in the Picker Column. Can be used as an alternative to swiping up and down. |
The Swipe Up and Swipe Down gestures rely on the correct key events being synthesized as noted on the slider documentation. Chromium-based browsers do not synthesize keyboard events correctly, but the "Double Tap and Slide Up/Down" gesture can be used as an alternative until this has been implemented in Chromium-based browsers.
Keyboard Interactions
Each Picker Column can be navigated using the keyboard when focused.
| Key | Description |
|---|---|
| ArrowUp | Scroll to the previous option. |
| ArrowDown | Scroll to the next option. |
| PageUp | Scroll up by more than one option. |
| PageDown | Scroll down by more than one option. |
| Home | Scroll to the first option. |
| End | Scroll to the last option. |
Properties
mode
| Description | The mode determines which platform styles to use. This is a virtual property that is set once during initialization and will not update if you change its value after the initial render. |
| Attribute | mode |
| Type | "ios" | "md" |
| Default | undefined |
Events
No events available for this component.
Methods
No public methods available for this component.
CSS Shadow Parts
No CSS shadow parts available for this component.
CSS Custom Properties
| Name | Description |
|---|---|
--fade-background-rgb | Background of the gradient covering non-selected items in rgb format |
--highlight-background | Background of the picker highlight for the selected item |
--highlight-border-radius | Border radius of the picker highlight for the selected item |
Slots
No slots available for this component.