ion-back-button
back buttonは、クリックするとアプリのひとつ前の履歴に戻ります。modeに基づいてどのようにレンダリングし、ナビゲーションスタックに基づいていつ表示するかを知っていれば十分です。
back buttonの表示内容を変更するには、text と
icon のプロパティを使用します。
利用方法
<!-- Default back button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with a default href -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="home"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with custom text and icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button
[text]="buttonText"
[icon]="buttonIcon">
</ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with no text and custom icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="" icon="add"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Danger back button next to a menu button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button color="danger"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header> CopyCopied
<!-- Default back button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with a default href -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button default-href="home"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with custom text and icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="Volver" icon="close"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with no text and custom icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="" icon="add"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Danger back button next to a menu button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button color="danger"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header> CopyCopied
import React from 'react';
import { IonBackButton, IonHeader, IonToolbar, IonButtons, IonMenuButton, IonContent } from '@ionic/react';
export const BackButtonExample: React.FC = () => (
<IonContent>
{/*-- Default back button --*/}
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton />
</IonButtons>
</IonToolbar>
</IonHeader>
{/*-- Back button with a default href --*/}
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton defaultHref="home" />
</IonButtons>
</IonToolbar>
</IonHeader>
{/*-- Back button with custom text and icon --*/}
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton text="buttonText" icon="buttonIcon" />
</IonButtons>
</IonToolbar>
</IonHeader>
{/*-- Back button with no text and custom icon --*/}
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton text="" icon="add" />
</IonButtons>
</IonToolbar>
</IonHeader>
{/*-- Danger back button next to a menu button --*/}
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonMenuButton />
<IonBackButton color="danger" />
</IonButtons>
</IonToolbar>
</IonHeader>
</IonContent>
); CopyCopied
import { Component, h } from '@stencil/core';
@Component({
tag: 'back-button-example',
styleUrl: 'back-button-example.css'
})
export class BackButtonExample {
render() {
const buttonText = "Custom";
const buttonIcon = "add";
return [
// Default back button
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>,
// Back button with a default href
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="home"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>,
// Back button with custom text and icon
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button
text={buttonText}
icon={buttonIcon}>
</ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>,
// Back button with no text and custom icon
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="" icon="add"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>,
// Danger back button next to a menu button
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button color="danger"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
];
}
} CopyCopied
<template>
<!-- Default back button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with a default href -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button default-href="home"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with custom text and icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button
:text="buttonText"
:icon="buttonIcon">
</ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Back button with no text and custom icon -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="" icon="add"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<!-- Danger back button next to a menu button -->
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button color="danger"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
</template>
<script>
import { IonButtons, IonHeader, IonMenuButton, IonToolbar } from '@ionic/vue';
import { defineComponent } from 'vue';
export default defineComponent({
components: { IonButtons, IonHeader, IonMenuButton, IonToolbar }
});
</script> CopyCopied
プロパティ
color | |
|---|---|
| Description | The color to use from your application's color palette.
Default options are: |
| Attribute | color |
| Type | string | undefined |
defaultHref | |
| Description | The url to navigate back to by default when there is no history. |
| Attribute | default-href |
| Type | string | undefined |
disabled | |
| Description | If |
| Attribute | disabled |
| Type | boolean |
| Default | false |
icon | |
| Description | The icon name to use for the back button. |
| Attribute | icon |
| Type | null | string | undefined |
mode | |
| Description | The mode determines which platform styles to use. |
| Attribute | mode |
| Type | "ios" | "md" |
routerAnimation | |
| Description | When using a router, it specifies the transition animation when navigating to another page. |
| Type | ((baseEl: any, opts?: any) => Animation) | undefined |
text | |
| Description | The text to display in the back button. |
| Attribute | text |
| Type | null | string | undefined |
type | |
| Description | The type of the button. |
| Attribute | type |
| Type | "button" | "reset" | "submit" |
| Default | 'button' |
CSS Shadow Parts
| Name | Description |
|---|---|
icon | The back button icon (uses ion-icon). |
native | The native HTML button element that wraps all child elements. |
text | The back button text. |
CSSカスタムプロパティ
| Name | Description |
|---|---|
--background | Background of the button |
--background-focused | Background of the button when focused with the tab key |
--background-focused-opacity | Opacity of the button background when focused with the tab key |
--background-hover | Background of the button on hover |
--background-hover-opacity | Opacity of the background on hover |
--border-radius | Border radius of the button |
--color | Text color of the button |
--color-focused | Text color of the button when focused with the tab key |
--color-hover | Text color of the button on hover |
--icon-font-size | Font size of the button icon |
--icon-font-weight | Font weight of the button icon |
--icon-margin-bottom | Bottom margin of the button icon |
--icon-margin-end | Right margin if direction is left-to-right, and left margin if direction is right-to-left of the button icon |
--icon-margin-start | Left margin if direction is left-to-right, and right margin if direction is right-to-left of the button icon |
--icon-margin-top | Top margin of the button icon |
--icon-padding-bottom | Bottom padding of the button icon |
--icon-padding-end | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button icon |
--icon-padding-start | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button icon |
--icon-padding-top | Top padding of the button icon |
--margin-bottom | Bottom margin of the button |
--margin-end | Right margin if direction is left-to-right, and left margin if direction is right-to-left of the button |
--margin-start | Left margin if direction is left-to-right, and right margin if direction is right-to-left of the button |
--margin-top | Top margin of the button |
--min-height | Minimum height of the button |
--min-width | Minimum width of the button |
--opacity | Opacity of the button |
--padding-bottom | Bottom padding of the button |
--padding-end | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button |
--padding-start | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button |
--padding-top | Top padding of the button |
--ripple-color | Color of the button ripple effect |
--transition | Transition of the button |

