ion-item
Items are elements that can contain text, icons, avatars, images, inputs, and any other native or custom elements. Generally they are placed in a list with other items. Items can be swiped, deleted, reordered, edited, and more.
Clickable Items
An item is considered "clickable" if it has an href
or button
property set. Clickable items have a few visual differences that indicate they can be interacted with. For example, a clickable item receives the ripple effect upon activation in md
mode, has a highlight when activated in ios
mode, and has a detail arrow by default in ios
mode.
Detail Arrows
By default clickable items will display a right arrow icon on ios
mode. To hide the right arrow icon on clickable elements, set the detail
property to false
. To show the right arrow icon on an item that doesn't display it naturally, set the detail
property to true
.
Item Placement
Item uses named slots in order to position content. This logic makes it possible to write a complex item with simple, understandable markup without having to worry about styling and positioning the elements.
The below chart details the item slots and where it will place the element inside of the item:
Slot | Description |
---|---|
start | Placed to the left of all other content in LTR, and to the right in RTL. |
end | Placed to the right of all other content in LTR, and to the left in RTL. |
none | Placed inside of the input wrapper. |
Text Alignment
Items left align text and add an ellipsis when the text is wider than the item. See the CSS Utilities Documentation for classes that can be added to <ion-item>
to transform the text.
Input Highlight
Highlight Height
Items containing an input will highlight the bottom border of the input with a different color when focused, valid, or invalid. By default, md
items have a highlight with a height set to 2px
and ios
has no highlight (technically the height is set to 0
). The height can be changed using the --highlight-height
CSS property. To turn off the highlight, set this variable to 0
. For more information on setting CSS properties, see the theming documentation.
Highlight Color
The highlight color changes based on the item state, but all of the states use Ionic colors by default. When focused, the input highlight will use the primary
color. If the input is valid it will use the success
color, and invalid inputs will use the danger
color. See the CSS Custom Properties section below for the highlight color variables.
Usage
- Angular
- Javascript
- React
- Stencil
- Vue
<!-- Default Item -->
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<!-- Item as a Button -->
<ion-item button (click)="buttonClick()">
<ion-label> Button Item </ion-label>
</ion-item>
<!-- Item as an Anchor -->
<ion-item href="https://www.ionicframework.com">
<ion-label> Anchor Item </ion-label>
</ion-item>
<ion-item color="secondary">
<ion-label> Secondary Color Item </ion-label>
</ion-item>
Detail Arrows
<ion-item detail>
<ion-label> Standard Item with Detail Arrow </ion-label>
</ion-item>
<ion-item button (click)="buttonClick()" detail>
<ion-label> Button Item with Detail Arrow </ion-label>
</ion-item>
<ion-item detail="false" href="https://www.ionicframework.com">
<ion-label> Anchor Item with no Detail Arrow </ion-label>
</ion-item>
List Items
<ion-list>
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<ion-item lines="none">
<ion-label> No Lines Item </ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
Multiline text that should wrap when it is too long to fit on one line in the item.
</ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
<ion-text color="primary">
<h3>H3 Primary Title</h3>
</ion-text>
<p>Paragraph line 1</p>
<ion-text color="secondary">
<p>Paragraph line 2 secondary</p>
</ion-text>
</ion-label>
</ion-item>
<ion-item lines="full">
<ion-label> Item with Full Lines </ion-label>
</ion-item>
</ion-list>
Item Lines
<!-- Item Inset Lines -->
<ion-item lines="inset">
<ion-label>Item Lines Inset</ion-label>
</ion-item>
<!-- Item Full Lines -->
<ion-item lines="full">
<ion-label>Item Lines Full</ion-label>
</ion-item>
<!-- Item None Lines -->
<ion-item lines="none">
<ion-label>Item Lines None</ion-label>
</ion-item>
<!-- List Full Lines -->
<ion-list lines="full">
<ion-item>
<ion-label>Full Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Full Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List Inset Lines -->
<ion-list lines="inset">
<ion-item>
<ion-label>Inset Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Inset Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List No Lines -->
<ion-list lines="none">
<ion-item>
<ion-label>No lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 2</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 3</ion-label>
</ion-item>
</ion-list>
Media Items
<ion-item button (click)="testClick()">
<ion-avatar slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-avatar>
<ion-label> Avatar Start, Button Item </ion-label>
</ion-item>
<ion-item href="#">
<ion-label> Thumbnail End, Anchor Item </ion-label>
<ion-thumbnail slot="end">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
</ion-item>
<ion-item>
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h2>H2 Title Text</h2>
<p>Button on right</p>
</ion-label>
<ion-button fill="outline" slot="end">View</ion-button>
</ion-item>
<ion-item button (click)="testClick()">
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h3>H3 Title Text</h3>
<p>Icon on right</p>
</ion-label>
<ion-icon name="close-circle" slot="end"></ion-icon>
</ion-item>
Buttons in Items
<ion-item>
<ion-button slot="start"> Start </ion-button>
<ion-label>Button Start/End</ion-label>
<ion-button slot="end"> End </ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
Start Icon
<ion-icon name="home" slot="end"></ion-icon>
</ion-button>
<ion-label>Buttons with Icons</ion-label>
<ion-button slot="end">
<ion-icon name="star" slot="end"></ion-icon>
End Icon
</ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
<ion-icon slot="icon-only" name="navigate"></ion-icon>
</ion-button>
<ion-label>Icon only Buttons</ion-label>
<ion-button slot="end">
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
</ion-item>
Icons in Items
<ion-item>
<ion-label> Icon End </ion-label>
<ion-icon name="information-circle" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Large Icon End </ion-label>
<ion-icon name="information-circle" size="large" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Small Icon End </ion-label>
<ion-icon name="information-circle" size="small" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-icon name="star" slot="start"></ion-icon>
<ion-label> Icon Start </ion-label>
</ion-item>
<ion-item>
<ion-label> Two Icons End </ion-label>
<ion-icon name="checkmark-circle" slot="end"></ion-icon>
<ion-icon name="shuffle" slot="end"></ion-icon>
</ion-item>
Item Inputs
<ion-item>
<ion-label position="floating">Datetime</ion-label>
<ion-datetime></ion-datetime>
</ion-item>
<ion-item>
<ion-label position="floating">Select</ion-label>
<ion-select>
<ion-select-option value="">No Game Console</ion-select-option>
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64" selected>Nintendo64</ion-select-option>
<ion-select-option value="ps">PlayStation</ion-select-option>
<ion-select-option value="genesis">Sega Genesis</ion-select-option>
<ion-select-option value="saturn">Sega Saturn</ion-select-option>
<ion-select-option value="snes">SNES</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Toggle</ion-label>
<ion-toggle slot="end"></ion-toggle>
</ion-item>
<ion-item>
<ion-label position="floating">Floating Input</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>Input (placeholder)</ion-label>
<ion-input placeholder="Placeholder"></ion-input>
</ion-item>
<ion-item>
<ion-label>Checkbox</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>Range</ion-label>
<ion-range></ion-range>
</ion-item>
<!-- Default Item -->
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<!-- Item as a Button -->
<ion-item button onclick="buttonClick()">
<ion-label> Button Item </ion-label>
</ion-item>
<!-- Item as an Anchor -->
<ion-item href="https://www.ionicframework.com">
<ion-label> Anchor Item </ion-label>
</ion-item>
<ion-item color="secondary">
<ion-label> Secondary Color Item </ion-label>
</ion-item>
Detail Arrows
<ion-item detail>
<ion-label> Standard Item with Detail Arrow </ion-label>
</ion-item>
<ion-item button onclick="buttonClick()" detail>
<ion-label> Button Item with Detail Arrow </ion-label>
</ion-item>
<ion-item detail="false" href="https://www.ionicframework.com">
<ion-label> Anchor Item with no Detail Arrow </ion-label>
</ion-item>
List Items
<ion-list>
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<ion-item lines="none">
<ion-label> No Lines Item </ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
Multiline text that should wrap when it is too long to fit on one line in the item.
</ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
<ion-text color="primary">
<h3>H3 Primary Title</h3>
</ion-text>
<p>Paragraph line 1</p>
<ion-text color="secondary">
<p>Paragraph line 2 secondary</p>
</ion-text>
</ion-label>
</ion-item>
<ion-item lines="full">
<ion-label> Item with Full Lines </ion-label>
</ion-item>
</ion-list>
Item Lines
<!-- Item Inset Lines -->
<ion-item lines="inset">
<ion-label>Item Lines Inset</ion-label>
</ion-item>
<!-- Item Full Lines -->
<ion-item lines="full">
<ion-label>Item Lines Full</ion-label>
</ion-item>
<!-- Item None Lines -->
<ion-item lines="none">
<ion-label>Item Lines None</ion-label>
</ion-item>
<!-- List Full Lines -->
<ion-list lines="full">
<ion-item>
<ion-label>Full Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Full Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List Inset Lines -->
<ion-list lines="inset">
<ion-item>
<ion-label>Inset Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Inset Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List No Lines -->
<ion-list lines="none">
<ion-item>
<ion-label>No lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 2</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 3</ion-label>
</ion-item>
</ion-list>
Media Items
<ion-item button onclick="testClick()">
<ion-avatar slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-avatar>
<ion-label> Avatar Start, Button Item </ion-label>
</ion-item>
<ion-item href="#">
<ion-label> Thumbnail End, Anchor Item </ion-label>
<ion-thumbnail slot="end">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
</ion-item>
<ion-item>
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h2>H2 Title Text</h2>
<p>Button on right</p>
</ion-label>
<ion-button fill="outline" slot="end">View</ion-button>
</ion-item>
<ion-item button onclick="testClick()">
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h3>H3 Title Text</h3>
<p>Icon on right</p>
</ion-label>
<ion-icon name="close-circle" slot="end"></ion-icon>
</ion-item>
Buttons in Items
<ion-item>
<ion-button slot="start"> Start </ion-button>
<ion-label>Button Start/End</ion-label>
<ion-button slot="end"> End </ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
Start Icon
<ion-icon name="home" slot="end"></ion-icon>
</ion-button>
<ion-label>Buttons with Icons</ion-label>
<ion-button slot="end">
<ion-icon name="star" slot="end"></ion-icon>
End Icon
</ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
<ion-icon slot="icon-only" name="navigate"></ion-icon>
</ion-button>
<ion-label>Icon only Buttons</ion-label>
<ion-button slot="end">
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
</ion-item>
Icons in Items
<ion-item>
<ion-label> Icon End </ion-label>
<ion-icon name="information-circle" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Large Icon End </ion-label>
<ion-icon name="information-circle" size="large" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Small Icon End </ion-label>
<ion-icon name="information-circle" size="small" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-icon name="star" slot="start"></ion-icon>
<ion-label> Icon Start </ion-label>
</ion-item>
<ion-item>
<ion-label> Two Icons End </ion-label>
<ion-icon name="checkmark-circle" slot="end"></ion-icon>
<ion-icon name="shuffle" slot="end"></ion-icon>
</ion-item>
Item Inputs
<ion-item>
<ion-label position="floating">Datetime</ion-label>
<ion-datetime></ion-datetime>
</ion-item>
<ion-item>
<ion-label position="floating">Select</ion-label>
<ion-select>
<ion-select-option value="">No Game Console</ion-select-option>
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64" selected>Nintendo64</ion-select-option>
<ion-select-option value="ps">PlayStation</ion-select-option>
<ion-select-option value="genesis">Sega Genesis</ion-select-option>
<ion-select-option value="saturn">Sega Saturn</ion-select-option>
<ion-select-option value="snes">SNES</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Toggle</ion-label>
<ion-toggle slot="end"></ion-toggle>
</ion-item>
<ion-item>
<ion-label position="floating">Floating Input</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>Input (placeholder)</ion-label>
<ion-input placeholder="Placeholder"></ion-input>
</ion-item>
<ion-item>
<ion-label>Checkbox</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>Range</ion-label>
<ion-range></ion-range>
</ion-item>
import React from 'react';
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, IonItem, IonLabel, IonList, IonText, IonAvatar, IonThumbnail, IonButton, IonIcon, IonDatetime, IonSelect, IonSelectOption, IonToggle, IonInput, IonCheckbox, IonRange } from '@ionic/react';
import { closeCircle, home, star, navigate, informationCircle, checkmarkCircle, shuffle } from 'ionicons/icons';
export const ItemExamples: React.FC = () => {
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>ItemExamples</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
{/*-- Default Item --*/}
<IonItem>
<IonLabel>
Item
</IonLabel>
</IonItem>
{/*-- Item as a Button --*/}
<IonItem button onClick={() => { }}>
<IonLabel>
Button Item
</IonLabel>
</IonItem>
{/*-- Item as an Anchor --*/}
<IonItem href="https://www.ionicframework.com">
<IonLabel>
Anchor Item
</IonLabel>
</IonItem>
<IonItem color="secondary">
<IonLabel>
Secondary Color Item
</IonLabel>
</IonItem>
{/*-- Detail Arrows --*/}
<IonItem detail>
<IonLabel>
Standard Item with Detail Arrow
</IonLabel>
</IonItem>
<IonItem button onClick={() => { }} detail>
<IonLabel>
Button Item with Detail Arrow
</IonLabel>
</IonItem>
<IonItem detail={false} href="https://www.ionicframework.com">
<IonLabel>
Anchor Item with no Detail Arrow
</IonLabel>
</IonItem>
<IonList>
<IonItem>
<IonLabel>
Item
</IonLabel>
</IonItem>
<IonItem lines="none">
<IonLabel>
No Lines Item
</IonLabel>
</IonItem>
<IonItem>
<IonLabel className="ion-text-wrap">
Multiline text that should wrap when it is too long
to fit on one line in the item.
</IonLabel>
</IonItem>
<IonItem>
<IonLabel className="ion-text-wrap">
<IonText color="primary">
<h3>H3 Primary Title</h3>
</IonText>
<p>Paragraph line 1</p>
<IonText color="secondary">
<p>Paragraph line 2 secondary</p>
</IonText>
</IonLabel>
</IonItem>
<IonItem lines="full">
<IonLabel>
Item with Full Lines
</IonLabel>
</IonItem>
</IonList>
{/*-- Item Inset Lines --*/}
<IonItem lines="inset">
<IonLabel>Item Lines Inset</IonLabel>
</IonItem>
{/*-- Item Full Lines --*/}
<IonItem lines="full">
<IonLabel>Item Lines Full</IonLabel>
</IonItem>
{/*-- Item None Lines --*/}
<IonItem lines="none">
<IonLabel>Item Lines None</IonLabel>
</IonItem>
{/*-- List Full Lines --*/}
<IonList lines="full">
<IonItem>
<IonLabel>Full Lines Item 1</IonLabel>
</IonItem>
<IonItem>
<IonLabel>Full Lines Item 2</IonLabel>
</IonItem>
</IonList>
{/*-- List Inset Lines --*/}
<IonList lines="inset">
<IonItem>
<IonLabel>Inset Lines Item 1</IonLabel>
</IonItem>
<IonItem>
<IonLabel>Inset Lines Item 2</IonLabel>
</IonItem>
</IonList>
{/*-- List No Lines --*/}
<IonList lines="none">
<IonItem>
<IonLabel>No lines Item 1</IonLabel>
</IonItem>
<IonItem>
<IonLabel>No lines Item 2</IonLabel>
</IonItem>
<IonItem>
<IonLabel>No lines Item 3</IonLabel>
</IonItem>
</IonList>
<IonItem button onClick={() => { }}>
<IonAvatar slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</IonAvatar>
<IonLabel>
Avatar Start, Button Item
</IonLabel>
</IonItem>
<IonItem href="#">
<IonLabel>
Thumbnail End, Anchor Item
</IonLabel>
<IonThumbnail slot="end">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</IonThumbnail>
</IonItem>
<IonItem>
<IonThumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</IonThumbnail>
<IonLabel>
<h2>H2 Title Text</h2>
<p>Button on right</p>
</IonLabel>
<IonButton fill="outline" slot="end">View</IonButton>
</IonItem>
<IonItem button onClick={() => { }}>
<IonThumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</IonThumbnail>
<IonLabel>
<h3>H3 Title Text</h3>
<p>Icon on right</p>
</IonLabel>
<IonIcon icon={closeCircle} slot="end" />
</IonItem>
{/*-- Buttons in Items --*/}
<IonItem>
<IonButton slot="start">
Start
</IonButton>
<IonLabel>Button Start/End</IonLabel>
<IonButton slot="end">
End
</IonButton>
</IonItem>
<IonItem>
<IonButton slot="start">
Start Icon
<IonIcon icon={home} slot="end" />>
</IonButton>
<IonLabel>Buttons with Icons</IonLabel>
<IonButton slot="end">
<IonIcon icon={star} slot="end" />
End Icon
</IonButton>
</IonItem>
<IonItem>
<IonButton slot="start">
<IonIcon slot="icon-only" icon={navigate} />
</IonButton>
<IonLabel>Icon only Buttons</IonLabel>
<IonButton slot="end">
<IonIcon slot="icon-only" icon={star} />
</IonButton>
</IonItem>
<IonItem>
<IonLabel>
Icon End
</IonLabel>
<IonIcon icon={informationCircle} slot="end" />
</IonItem>
<IonItem>
<IonLabel>
Large Icon End
</IonLabel>
<IonIcon icon={informationCircle} size="large" slot="end" />
</IonItem>
<IonItem>
<IonLabel>
Small Icon End
</IonLabel>
<IonIcon icon={informationCircle} size="small" slot="end" />
</IonItem>
<IonItem>
<IonIcon icon={star} slot="start" />
<IonLabel>
Icon Start
</IonLabel>
</IonItem>
<IonItem>
<IonLabel>
Two Icons End
</IonLabel>
<IonIcon icon={checkmarkCircle} slot="end" />
<IonIcon icon={shuffle} slot="end" />
</IonItem>
<IonItem>
<IonLabel position="floating">Datetime</IonLabel>
<IonDatetime></IonDatetime>
</IonItem>
<IonItem>
<IonLabel position="floating">Select</IonLabel>
<IonSelect>
<IonSelectOption value="">No Game Console</IonSelectOption>
<IonSelectOption value="nes">NES</IonSelectOption>
<IonSelectOption value="n64">Nintendo64</IonSelectOption>
<IonSelectOption value="ps">PlayStation</IonSelectOption>
<IonSelectOption value="genesis">Sega Genesis</IonSelectOption>
<IonSelectOption value="saturn">Sega Saturn</IonSelectOption>
<IonSelectOption value="snes">SNES</IonSelectOption>
</IonSelect>
</IonItem>
<IonItem>
<IonLabel>Toggle</IonLabel>
<IonToggle slot="end"></IonToggle>
</IonItem>
<IonItem>
<IonLabel position="floating">Floating Input</IonLabel>
<IonInput></IonInput>
</IonItem>
<IonItem>
<IonLabel>Input (placeholder)</IonLabel>
<IonInput placeholder="Placeholder"></IonInput>
</IonItem>
<IonItem>
<IonLabel>Checkbox</IonLabel>
<IonCheckbox slot="start" />
</IonItem>
<IonItem>
<IonLabel>Range</IonLabel>
<IonRange></IonRange>
</IonItem>
</IonContent>
</IonPage>
);
};
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
buttonClick() {
console.log('Clicked button');
}
render() {
return [
// Default Item
<ion-item>
<ion-label>Item</ion-label>
</ion-item>,
// Item as a Button
<ion-item button onClick={() => this.buttonClick()}>
<ion-label>Button Item</ion-label>
</ion-item>,
// Item as an Anchor
<ion-item href="https://www.ionicframework.com">
<ion-label>Anchor Item</ion-label>
</ion-item>,
<ion-item color="secondary">
<ion-label>Secondary Color Item</ion-label>
</ion-item>,
];
}
}
Detail Arrows
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
buttonClick() {
console.log('Clicked button');
}
render() {
return [
<ion-item detail>
<ion-label>Standard Item with Detail Arrow</ion-label>
</ion-item>,
<ion-item button onClick={() => this.buttonClick()} detail>
<ion-label>Button Item with Detail Arrow</ion-label>
</ion-item>,
<ion-item detail={false} href="https://www.ionicframework.com">
<ion-label>Anchor Item with no Detail Arrow</ion-label>
</ion-item>,
];
}
}
List Items
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
render() {
return [
<ion-list>
<ion-item>
<ion-label>Item</ion-label>
</ion-item>
<ion-item lines="none">
<ion-label>No Lines Item</ion-label>
</ion-item>,<ion-item>
<ion-label class="ion-text-wrap">
Multiline text that should wrap when it is too long to fit on one line in the item.
</ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
<ion-text color="primary">
<h3>H3 Primary Title</h3>
</ion-text>
<p>Paragraph line 1</p>
<ion-text color="secondary">
<p>Paragraph line 2 secondary</p>
</ion-text>
</ion-label>
</ion-item>
<ion-item lines="full">
<ion-label>Item with Full Lines</ion-label>
</ion-item>
</ion-list>,
];
}
}
Item Lines
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
render() {
return [
// Item Inset Lines
<ion-item lines="inset">
<ion-label>Item Lines Inset</ion-label>
</ion-item>,
// Item Full Lines
<ion-item lines="full">
<ion-label>Item Lines Full</ion-label>
</ion-item>,
// Item None Lines
<ion-item lines="none">
<ion-label>Item Lines None</ion-label>
</ion-item>,
// List Full Lines
<ion-list lines="full">
<ion-item>
<ion-label>Full Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Full Lines Item 2</ion-label>
</ion-item>
</ion-list>,
// List Inset Lines
<ion-list lines="inset">
<ion-item>
<ion-label>Inset Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Inset Lines Item 2</ion-label>
</ion-item>
</ion-list>,
// List No Lines
<ion-list lines="none">
<ion-item>
<ion-label>No lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 2</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 3</ion-label>
</ion-item>
</ion-list>,
];
}
}
Media Items
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
testClick() {
console.log('Test click');
}
render() {
return [
<ion-item button onClick={() => this.testClick()}>
<ion-avatar slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-avatar>
<ion-label>Avatar Start, Button Item</ion-label>
</ion-item>,
<ion-item href="#">
<ion-label>Thumbnail End, Anchor Item</ion-label>
<ion-thumbnail slot="end">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
</ion-item>,
<ion-item>
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h2>H2 Title Text</h2>
<p>Button on right</p>
</ion-label>
<ion-button fill="outline" slot="end">
View
</ion-button>
</ion-item>,
<ion-item button onClick={() => this.testClick()}>
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h3>H3 Title Text</h3>
<p>Icon on right</p>
</ion-label>
<ion-icon name="close-circle" slot="end"></ion-icon>
</ion-item>,
];
}
}
Buttons in Items
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
render() {
return [
<ion-item>
<ion-button slot="start">Start</ion-button>
<ion-label>Button Start/End</ion-label>
<ion-button slot="end">End</ion-button>
</ion-item>,
<ion-item>
<ion-button slot="start">
Start Icon
<ion-icon name="home" slot="end"></ion-icon>
</ion-button>
<ion-label>Buttons with Icons</ion-label>
<ion-button slot="end">
<ion-icon name="star" slot="end"></ion-icon>
End Icon
</ion-button>
</ion-item>,
<ion-item>
<ion-button slot="start">
<ion-icon slot="icon-only" name="navigate"></ion-icon>
</ion-button>
<ion-label>Icon only Buttons</ion-label>
<ion-button slot="end">
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
</ion-item>,
];
}
}
Icons in Items
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
render() {
return [
<ion-item>
<ion-label>Icon End</ion-label>
<ion-icon name="information-circle" slot="end"></ion-icon>
</ion-item>,
<ion-item>
<ion-label>Large Icon End</ion-label>
<ion-icon name="information-circle" size="large" slot="end"></ion-icon>
</ion-item>,
<ion-item>
<ion-label>Small Icon End</ion-label>
<ion-icon name="information-circle" size="small" slot="end"></ion-icon>
</ion-item>,
<ion-item>
<ion-icon name="star" slot="start"></ion-icon>
<ion-label>Icon Start</ion-label>
</ion-item>,
<ion-item>
<ion-label>Two Icons End</ion-label>
<ion-icon name="checkmark-circle" slot="end"></ion-icon>
<ion-icon name="shuffle" slot="end"></ion-icon>
</ion-item>,
];
}
}
Item Inputs
import { Component, h } from '@stencil/core';
@Component({
tag: 'item-example',
styleUrl: 'item-example.css',
})
export class ItemExample {
render() {
return [
<ion-item>
<ion-label position="floating">Datetime</ion-label>
<ion-datetime></ion-datetime>
</ion-item>,
<ion-item>
<ion-label position="floating">Select</ion-label>
<ion-select>
<ion-select-option value="">No Game Console</ion-select-option>
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64" selected>
Nintendo64
</ion-select-option>
<ion-select-option value="ps">PlayStation</ion-select-option>
<ion-select-option value="genesis">Sega Genesis</ion-select-option>
<ion-select-option value="saturn">Sega Saturn</ion-select-option>
<ion-select-option value="snes">SNES</ion-select-option>
</ion-select>
</ion-item>,
<ion-item>
<ion-label>Toggle</ion-label>
<ion-toggle slot="end"></ion-toggle>
</ion-item>,
<ion-item>
<ion-label position="floating">Floating Input</ion-label>
<ion-input></ion-input>
</ion-item>,
<ion-item>
<ion-label>Input (placeholder)</ion-label>
<ion-input placeholder="Placeholder"></ion-input>
</ion-item>,
<ion-item>
<ion-label>Checkbox</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>,
<ion-item>
<ion-label>Range</ion-label>
<ion-range></ion-range>
</ion-item>,
];
}
}
<template>
<!-- Default Item -->
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<!-- Item as a Button -->
<ion-item button @click="buttonClick()">
<ion-label> Button Item </ion-label>
</ion-item>
<!-- Item as an Anchor -->
<ion-item href="https://www.ionicframework.com">
<ion-label> Anchor Item </ion-label>
</ion-item>
<ion-item color="secondary">
<ion-label> Secondary Color Item </ion-label>
</ion-item>
</template>
Detail Arrows
<template>
<ion-item detail>
<ion-label> Standard Item with Detail Arrow </ion-label>
</ion-item>
<ion-item button @click="buttonClick()" detail>
<ion-label> Button Item with Detail Arrow </ion-label>
</ion-item>
<ion-item detail="false" href="https://www.ionicframework.com">
<ion-label> Anchor Item with no Detail Arrow </ion-label>
</ion-item>
</template>
List Items
<template>
<ion-list>
<ion-item>
<ion-label> Item </ion-label>
</ion-item>
<ion-item lines="none">
<ion-label> No Lines Item </ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
Multiline text that should wrap when it is too long to fit on one line in the item.
</ion-label>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">
<ion-text color="primary">
<h3>H3 Primary Title</h3>
</ion-text>
<p>Paragraph line 1</p>
<ion-text color="secondary">
<p>Paragraph line 2 secondary</p>
</ion-text>
</ion-label>
</ion-item>
<ion-item lines="full">
<ion-label> Item with Full Lines </ion-label>
</ion-item>
</ion-list>
</template>
Item Lines
<template>
<!-- Item Inset Lines -->
<ion-item lines="inset">
<ion-label>Item Lines Inset</ion-label>
</ion-item>
<!-- Item Full Lines -->
<ion-item lines="full">
<ion-label>Item Lines Full</ion-label>
</ion-item>
<!-- Item None Lines -->
<ion-item lines="none">
<ion-label>Item Lines None</ion-label>
</ion-item>
<!-- List Full Lines -->
<ion-list lines="full">
<ion-item>
<ion-label>Full Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Full Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List Inset Lines -->
<ion-list lines="inset">
<ion-item>
<ion-label>Inset Lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>Inset Lines Item 2</ion-label>
</ion-item>
</ion-list>
<!-- List No Lines -->
<ion-list lines="none">
<ion-item>
<ion-label>No lines Item 1</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 2</ion-label>
</ion-item>
<ion-item>
<ion-label>No lines Item 3</ion-label>
</ion-item>
</ion-list>
</template>
Media Items
<template>
<ion-item button @click="testClick()">
<ion-avatar slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-avatar>
<ion-label> Avatar Start, Button Item </ion-label>
</ion-item>
<ion-item href="#">
<ion-label> Thumbnail End, Anchor Item </ion-label>
<ion-thumbnail slot="end">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
</ion-item>
<ion-item>
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h2>H2 Title Text</h2>
<p>Button on right</p>
</ion-label>
<ion-button fill="outline" slot="end">View</ion-button>
</ion-item>
<ion-item button @click="testClick()">
<ion-thumbnail slot="start">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==" />
</ion-thumbnail>
<ion-label>
<h3>H3 Title Text</h3>
<p>Icon on right</p>
</ion-label>
<ion-icon :icon="closeCircle" slot="end"></ion-icon>
</ion-item>
</template>
Buttons in Items
<template>
<ion-item>
<ion-button slot="start"> Start </ion-button>
<ion-label>Button Start/End</ion-label>
<ion-button slot="end"> End </ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
Start Icon
<ion-icon :icon="home" slot="end"></ion-icon>
</ion-button>
<ion-label>Buttons with Icons</ion-label>
<ion-button slot="end">
<ion-icon :icon="star" slot="end"></ion-icon>
End Icon
</ion-button>
</ion-item>
<ion-item>
<ion-button slot="start">
<ion-icon slot="icon-only" :icon="navigate"></ion-icon>
</ion-button>
<ion-label>Icon only Buttons</ion-label>
<ion-button slot="end">
<ion-icon slot="icon-only" :icon="star"></ion-icon>
</ion-button>
</ion-item>
</template>
Icons in Items
<template>
<ion-item>
<ion-label> Icon End </ion-label>
<ion-icon :icon="informationCircle" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Large Icon End </ion-label>
<ion-icon :icon="informationCircle" size="large" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-label> Small Icon End </ion-label>
<ion-icon :icon="informationCircle" size="small" slot="end"></ion-icon>
</ion-item>
<ion-item>
<ion-icon :icon="star" slot="start"></ion-icon>
<ion-label> Icon Start </ion-label>
</ion-item>
<ion-item>
<ion-label> Two Icons End </ion-label>
<ion-icon :icon="checkmarkCircle" slot="end"></ion-icon>
<ion-icon :icon="shuffle" slot="end"></ion-icon>
</ion-item>
</template>
Item Inputs
<template>
<ion-item>
<ion-label position="floating">Datetime</ion-label>
<ion-datetime></ion-datetime>
</ion-item>
<ion-item>
<ion-label position="floating">Select</ion-label>
<ion-select>
<ion-select-option value="">No Game Console</ion-select-option>
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64" selected>Nintendo64</ion-select-option>
<ion-select-option value="ps">PlayStation</ion-select-option>
<ion-select-option value="genesis">Sega Genesis</ion-select-option>
<ion-select-option value="saturn">Sega Saturn</ion-select-option>
<ion-select-option value="snes">SNES</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Toggle</ion-label>
<ion-toggle slot="end"></ion-toggle>
</ion-item>
<ion-item>
<ion-label position="floating">Floating Input</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>Input (placeholder)</ion-label>
<ion-input placeholder="Placeholder"></ion-input>
</ion-item>
<ion-item>
<ion-label>Checkbox</ion-label>
<ion-checkbox slot="start"></ion-checkbox>
</ion-item>
<ion-item>
<ion-label>Range</ion-label>
<ion-range></ion-range>
</ion-item>
</template>
<script>
import {
IonAvatar,
IonButton,
IonCheckbox,
IonDatetime,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonRange,
IonSelect,
IonSelectOption,
IonText,
IonThumbnail,
IonToggle,
} from '@ionic/vue';
import { checkmarkCircle, closeCircle, home, informationCircle, navigate, shuffle, star } from 'ionicons/icons';
import { defineComponent } from 'vue';
export default defineComponent({
components: {
IonAvatar,
IonButton,
IonCheckbox,
IonDatetime,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonRange,
IonSelect,
IonSelectOption,
IonText,
IonThumbnail,
IonToggle,
},
setup() {
return {
checkmarkCircle,
closeCircle,
home,
informationCircle,
navigate,
shuffle,
star,
};
},
});
</script>
Properties
button
Description | true の場合、ボタンタグがレンダリングされ、アイテムはタップ可能になる。 |
Attribute | button |
Type | boolean |
Default | false |
color
Description | The color to use from your application's color palette. Default options are: "primary" , "secondary" , "tertiary" , "success" , "warning" , "danger" , "light" , "medium" , and "dark" . For more information on colors, see theming. |
Attribute | color |
Type | string | undefined |
Default | undefined |
detail
Description | If true , a detail arrow will appear on the item. Defaults to false unless the mode is ios and an href or button property is present. |
Attribute | detail |
Type | boolean | undefined |
Default | undefined |
detailIcon
Description | detail が true に設定されているときに使用するアイコンです。 |
Attribute | detail-icon |
Type | string |
Default | 'chevron-forward' |
disabled
Description | true の場合、ユーザはそのアイテムと対話することができません。 |
Attribute | disabled |
Type | boolean |
Default | false |
download
Description | This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want). |
Attribute | download |
Type | string | undefined |
Default | undefined |
href
Description | Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered. |
Attribute | href |
Type | string | undefined |
Default | undefined |
lines
Description | アイテムに表示される下枠の表示方法。 |
Attribute | lines |
Type | "full" | "inset" | "none" | undefined |
Default | undefined |
mode
Description | modeは、どのプラットフォームのスタイルを使用するかを決定します。 |
Attribute | mode |
Type | "ios" | "md" |
Default | undefined |
rel
Description | Specifies the relationship of the target object to the link object. The value is a space-separated list of link types. |
Attribute | rel |
Type | string | undefined |
Default | undefined |
routerAnimation
Description | When using a router, it specifies the transition animation when navigating to another page using href . |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) | undefined |
Default | undefined |
routerDirection
Description | When using a router, it specifies the transition direction when navigating to another page using href . |
Attribute | router-direction |
Type | "back" | "forward" | "root" |
Default | 'forward' |
target
Description | Specifies where to display the linked URL. Only applies when an href is provided. Special keywords: "_blank" , "_self" , "_parent" , "_top" . |
Attribute | target |
Type | string | undefined |
Default | undefined |
type
Description | ボタンの種類。onclickまたは button`プロパティが存在する場合にのみ使用される。 |
Attribute | type |
Type | "button" | "reset" | "submit" |
Default | 'button' |
Events
No events available for this component.
Methods
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
detail-icon | アイテムのシェブロンアイコンを表示します。detail="true"`のときのみ適用されます。 |
native | すべての子要素をラップするネイティブHTMLのボタン、アンカー、またはdiv要素です。 |
CSS Custom Properties
Name | Description |
---|---|
--background | アイテムの背景 |
--background-activated | 押されたときのアイテムの背景。注意:これを設定すると、Material Designの波紋に干渉します。 |
--background-activated-opacity | 押されたときのアイテム背景の不透明度 |
--background-focused | タブキーでフォーカスした ときのアイテムの背景 |
--background-focused-opacity | タブキーでフォーカスしたときのアイテムの背景の不透明度 |
--background-hover | ホバー時のアイテムの背景 |
--background-hover-opacity | ホバー時のアイテムの背景の不透明度 |
--border-color | アイテムの縁取りの色 |
--border-radius | アイテムの境界線の半径 |
--border-style | アイテムの枠のスタイル |
--border-width | アイテムの枠の幅 |
--color | アイテムのカラー |
--color-activated | 押したときのアイテムの色 |
--color-focused | タブキーでフォーカスしたときのアイテムの色 |
--color-hover | ホバー時のアイテムの色 |
--detail-icon-color | アイテム詳細アイコンの色 |
--detail-icon-font-size | アイテム詳細アイコンのFont Size |
--detail-icon-opacity | アイテム詳細アイコンの不透明度 |
--highlight-color-focused | フォーカスされたときのアイテムのハイライトの色 |
--highlight-color-invalid | 無効時のアイテムのハイライトの色 |
--highlight-color-valid | 有効時のアイテム上のハイライトの色 |
--highlight-height | アイテムに表示されるハイライトの高さ |
--inner-border-width | アイテム内枠の幅 |
--inner-box-shadow | アイテム内側のボック スシャドウ |
--inner-padding-bottom | アイテム内側のBottom Padding |
--inner-padding-end | 方向が左から右の場合はRight Padding、方向がアイテムの内側の右から左の場合はLeft Paddingとなります。 |
--inner-padding-start | 方向が左から右の場合はLeft Padding、方向が右から左の場合はRight Paddingがアイテム内側に入る |
--inner-padding-top | アイテム内側のTop Padding |
--min-height | アイテムの最小高さ |
--padding-bottom | アイテムのBottom Padding |
--padding-end | 方向が左から右の場合はRight Padding、方向が右から左の場合はLeft Paddingで項目を囲む |
--padding-start | 方向が左から右の場合はLeft Padding、方向が右から左の場合はRight Paddingで項目を囲む |
--padding-top | アイテムのTop Padding |
--ripple-color | アイテム波及効果の色 |
--transition | アイテムの変遷 |
Slots
Name | Description |
---|---|
`` | slotがない状態で提供される場合、コンテンツは名前付きslotの間に配置されます。 |
end | コンテンツは、LTRではアイテムテキストの右側に、RTLでは左側に配置されます。 |
start | コンテンツは、LTRではアイテムテキストの左側に、RTLでは右側に配置さ れます。 |