Flutter教程

ion-button

概要(CONTENTS)

Ionic4项目中我们可以使用Ionic4按钮组件ion-button对项目进行布局。

ion-button官方文档地址:https://ionicframework.com/docs/api/button

Buttons provide a clickable element, which can be used in forms, or anywhere that needs simple, standard button functionality. They may display text, icons, or both. Buttons can be styled with several attributes to look a specific way.

Expand

This attribute lets you specify how wide the button should be. By default, buttons are inline blocks, but setting this attribute will change the button to a full-width block element.

Value Details
block Full-width button with rounded corners.
full Full-width button with square corners and no border on the left or right.

Fill

This attributes determines the background and border color of the button. By default, buttons have a solid background unless the button is inside of a toolbar, in which case it has a transparent background.

Value Details
clear Button with a transparent background that resembles a flat button.
outline Button with a transparent background and a visible border.
solid Button with a filled background. Useful for buttons in a toolbar.

Size

This attribute specifies the size of the button. Setting this attribute will change the height and padding of a button.

Value Details
small Button with less height and padding. Default for buttons in an item.
default Button with the default height and padding. Useful for buttons in an item.
large Button with more height and padding.

ion-button 用法(Usage)


<ion-button>Defaultion-button>


<ion-button href="#">Anchorion-button>


<ion-button color="primary">Primaryion-button>
<ion-button color="secondary">Secondaryion-button>
<ion-button color="tertiary">Tertiaryion-button>
<ion-button color="success">Succession-button>
<ion-button color="warning">Warningion-button>
<ion-button color="danger">Dangerion-button>
<ion-button color="light">Lightion-button>
<ion-button color="medium">Mediumion-button>
<ion-button color="dark">Darkion-button>


<ion-button expand="full">Full Buttonion-button>
<ion-button expand="block">Block Buttonion-button>


<ion-button shape="round">Round Buttonion-button>


<ion-button expand="full" fill="outline">Outline + Fullion-button>
<ion-button expand="block" fill="outline">Outline + Blockion-button>
<ion-button shape="round" fill="outline">Outline + Roundion-button>


<ion-button>
  <ion-icon slot="start" name="star">ion-icon>
  Left Icon
ion-button>

<ion-button>
  Right Icon
  <ion-icon slot="end" name="star">ion-icon>
ion-button>

<ion-button>
  <ion-icon slot="icon-only" name="star">ion-icon>
ion-button>


<ion-button size="large">Largeion-button>
<ion-button>Defaultion-button>
<ion-button size="small">Smallion-button>

<ion-button>Defaultion-button>


<ion-button href="#">Anchorion-button>


<ion-button color="primary">Primaryion-button>
<ion-button color="secondary">Secondaryion-button>
<ion-button color="tertiary">Tertiaryion-button>
<ion-button color="success">Succession-button>
<ion-button color="warning">Warningion-button>
<ion-button color="danger">Dangerion-button>
<ion-button color="light">Lightion-button>
<ion-button color="medium">Mediumion-button>
<ion-button color="dark">Darkion-button>


<ion-button expand="full">Full Buttonion-button>
<ion-button expand="block">Block Buttonion-button>


<ion-button shape="round">Round Buttonion-button>


<ion-button expand="full" fill="outline">Outline + Fullion-button>
<ion-button expand="block" fill="outline">Outline + Blockion-button>
<ion-button shape="round" fill="outline">Outline + Roundion-button>


<ion-button>
  <ion-icon slot="start" name="star">ion-icon>
  Left Icon
ion-button>

<ion-button>
  Right Icon
  <ion-icon slot="end" name="star">ion-icon>
ion-button>

<ion-button>
  <ion-icon slot="icon-only" name="star">ion-icon>
ion-button>


<ion-button size="large">Largeion-button>
<ion-button>Defaultion-button>
<ion-button size="small">Smallion-button>
import React from 'react';

import { IonButton, IonIcon } from '@ionic/react';

const Example: React.SFC<{}> = () => (
  <>
    {/*-- Default --*/}
    <IonButton>DefaultIonButton>

    {/*-- Anchor --*/}
    <IonButton href="#">AnchorIonButton>

    {/*-- Colors --*/}
    <IonButton color="primary">PrimaryIonButton>
    <IonButton color="secondary">SecondaryIonButton>
    <IonButton color="tertiary">TertiaryIonButton>
    <IonButton color="success">SuccessIonButton>
    <IonButton color="warning">WarningIonButton>
    <IonButton color="danger">DangerIonButton>
    <IonButton color="light">LightIonButton>
    <IonButton color="medium">MediumIonButton>
    <IonButton color="dark">DarkIonButton>

    {/*-- Expand --*/}
    <IonButton expand="full">Full ButtonIonButton>
    <IonButton expand="block">Block ButtonIonButton>

    {/*-- Round --*/}
    <IonButton shape="round">Round ButtonIonButton>

    {/*-- Fill --*/}
    <IonButton expand="full" fill="outline">Outline + FullIonButton>
    <IonButton expand="block" fill="outline">Outline + BlockIonButton>
    <IonButton shape="round" fill="outline">Outline + RoundIonButton>

    {/*-- Icons --*/}
    <IonButton>
      <IonIcon slot="start" name="star" />
      Left Icon
    IonButton>

    <IonButton>
      Right Icon
      <IonIcon slot="end" name="star" />
    IonButton>

    <IonButton>
      <IonIcon slot="icon-only" name="star" />
    IonButton>

    {/*-- Sizes --*/}
    <IonButton size="large">LargeIonButton>
    <IonButton>DefaultIonButton>
    <IonButton size="small">SmallIonButton>
  >
);

export default Example;
<template>
  
  <ion-button>Defaultion-button>

  
  <ion-button href="#">Anchorion-button>

  
  <ion-button color="primary">Primaryion-button>
  <ion-button color="secondary">Secondaryion-button>
  <ion-button color="tertiary">Tertiaryion-button>
  <ion-button color="success">Succession-button>
  <ion-button color="warning">Warningion-button>
  <ion-button color="danger">Dangerion-button>
  <ion-button color="light">Lightion-button>
  <ion-button color="medium">Mediumion-button>
  <ion-button color="dark">Darkion-button>

  
  <ion-button expand="full">Full Buttonion-button>
  <ion-button expand="block">Block Buttonion-button>

  
  <ion-button shape="round">Round Buttonion-button>

  
  <ion-button expand="full" fill="outline">Outline + Fullion-button>
  <ion-button expand="block" fill="outline">Outline + Blockion-button>
  <ion-button shape="round" fill="outline">Outline + Roundion-button>

  
  <ion-button>
    <ion-icon slot="start" name="star">ion-icon>
    Left Icon
  ion-button>

  <ion-button>
    Right Icon
    <ion-icon slot="end" name="star">ion-icon>
  ion-button>

  <ion-button>
    <ion-icon slot="icon-only" name="star">ion-icon>
  ion-button>

  
  <ion-button size="large">Largeion-button>
  <ion-button>Defaultion-button>
  <ion-button size="small">Smallion-button>
template>

ion-button 属性(Properties)

buttonType

Description

The type of button.

Attribute button-type
Type string
Default 'button'

color