Bài 10: Tìm hiểu về Ion-button,Ion-ripple-effect

Bài 10: Tìm hiểu về Ion-button,Ion-ripple-effect


 

Ion-button

Các nút cung cấp một phần tử có thể nhấp, có thể được sử dụng trong các biểu mẫu hoặc bất kỳ nơi nào cần chức năng nút tiêu chuẩn, đơn giản. Chúng có thể hiển thị văn bản, biểu tượng hoặc cả hai. Các nút có thể được tạo kiểu với một số thuộc tính để trông theo một cách cụ thể.






Expand

Thuộc tính này cho phép bạn chỉ định độ rộng của nút. Theo mặc định, các nút là khối nội tuyến, nhưng việc đặt thuộc tính này sẽ thay đổi nút thành phần tử khối có chiều rộng đầy đủ.

Giá trịChi tiết
blockNút có chiều rộng đầy đủ với các góc được bo tròn.
fullNút có chiều rộng đầy đủ với các góc vuông và không có đường viền ở bên trái hoặc bên phải.

Fill

Thuộc tính này xác định màu nền và đường viền của nút. Theo mặc định, các nút có nền đặc trừ khi nút nằm bên trong thanh công cụ, trong trường hợp đó, nút có nền trong suốt.

Giá trịChi tiết
clearNút có nền trong suốt giống như nút phẳng.
outlineNút có nền trong suốt và đường viền có thể nhìn thấy được.
solidNút có nền được lấp đầy. Hữu ích cho các nút trên thanh công cụ.

Size

Thuộc tính này chỉ định kích thước của nút. Đặt thuộc tính này sẽ thay đổi chiều cao và phần đệm của nút.

Giá trịChi tiết
smallNút có ít chiều cao và đệm hơn. Mặc định cho các nút trong một mục.
defaultNút có chiều cao và phần đệm mặc định. Hữu ích cho các nút trong một mục.
largeNút có nhiều chiều cao và đệm hơn.

Usage

<!-- Default -->
<ion-button>Default</ion-button>

<!-- Anchor -->
<ion-button href="#">Anchor</ion-button>

<!-- Colors -->
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>

<!-- Expand -->
<ion-button expand="full">Full Button</ion-button>
<ion-button expand="block">Block Button</ion-button>

<!-- Round -->
<ion-button shape="round">Round Button</ion-button>

<!-- Fill -->
<ion-button expand="full" fill="outline">Outline + Full</ion-button>
<ion-button expand="block" fill="outline">Outline + Block</ion-button>
<ion-button shape="round" fill="outline">Outline + Round</ion-button>

<!-- Icons -->
<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>

<!-- Sizes -->
<ion-button size="large">Large</ion-button>
<ion-button>Default</ion-button>
<ion-button size="small">Small</ion-button>


<!-- Default -->
<ion-button>Default</ion-button>

<!-- Anchor -->
<ion-button href="#">Anchor</ion-button>

<!-- Colors -->
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>

<!-- Expand -->
<ion-button expand="full">Full Button</ion-button>
<ion-button expand="block">Block Button</ion-button>

<!-- Round -->
<ion-button shape="round">Round Button</ion-button>

<!-- Fill -->
<ion-button expand="full" fill="outline">Outline + Full</ion-button>
<ion-button expand="block" fill="outline">Outline + Block</ion-button>
<ion-button shape="round" fill="outline">Outline + Round</ion-button>

<!-- Icons -->
<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>

<!-- Sizes -->
<ion-button size="large">Large</ion-button>
<ion-button>Default</ion-button>
<ion-button size="small">Small</ion-button>

import React from 'react';

import { IonButton, IonIcon, IonContent } from '@ionic/react';
import { star } from 'ionicons/icons';

export const ButtonExample: React.FC = () => (
  <IonContent>
    {/*-- Default --*/}
    <IonButton>Default</IonButton>

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

    {/*-- Colors --*/}
    <IonButton color="primary">Primary</IonButton>
    <IonButton color="secondary">Secondary</IonButton>
    <IonButton color="tertiary">Tertiary</IonButton>
    <IonButton color="success">Success</IonButton>
    <IonButton color="warning">Warning</IonButton>
    <IonButton color="danger">Danger</IonButton>
    <IonButton color="light">Light</IonButton>
    <IonButton color="medium">Medium</IonButton>
    <IonButton color="dark">Dark</IonButton>

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

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

    {/*-- Fill --*/}
    <IonButton expand="full" fill="outline">Outline + Full</IonButton>
    <IonButton expand="block" fill="outline">Outline + Block</IonButton>
    <IonButton shape="round" fill="outline">Outline + Round</IonButton>

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

    <IonButton>
      Right Icon
      <IonIcon slot="end" icon={star} />
    </IonButton>

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

    {/*-- Sizes --*/}
    <IonButton size="large">Large</IonButton>
    <IonButton>Default</IonButton>
    <IonButton size="small">Small</IonButton>
  </IonContent>
);
import { Component, h } from '@stencil/core';

@Component({
  tag: 'button-example',
  styleUrl: 'button-example.css'
})
export class ButtonExample {
  render() {
    return [
      // Default
      <ion-button>Default</ion-button>,

      // Anchor
      <ion-button href="#">Anchor</ion-button>,

      // Colors
      <ion-button color="primary">Primary</ion-button>,
      <ion-button color="secondary">Secondary</ion-button>,
      <ion-button color="tertiary">Tertiary</ion-button>,
      <ion-button color="success">Success</ion-button>,
      <ion-button color="warning">Warning</ion-button>,
      <ion-button color="danger">Danger</ion-button>,
      <ion-button color="light">Light</ion-button>,
      <ion-button color="medium">Medium</ion-button>,
      <ion-button color="dark">Dark</ion-button>,

      // Expand
      <ion-button expand="full">Full Button</ion-button>,
      <ion-button expand="block">Block Button</ion-button>,

      // Round
      <ion-button shape="round">Round Button</ion-button>,

      // Fill
      <ion-button expand="full" fill="outline">Outline + Full</ion-button>,
      <ion-button expand="block" fill="outline">Outline + Block</ion-button>,
      <ion-button shape="round" fill="outline">Outline + Round</ion-button>,

      // Icons
      <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>,

      // Sizes
      <ion-button size="large">Large</ion-button>,
      <ion-button>Default</ion-button>,
      <ion-button size="small">Small</ion-button>
    ];
  }
}

<template>
  <!-- Default -->
  <ion-button>Default</ion-button>

  <!-- Anchor -->
  <ion-button href="#">Anchor</ion-button>

  <!-- Colors -->
  <ion-button color="primary">Primary</ion-button>
  <ion-button color="secondary">Secondary</ion-button>
  <ion-button color="tertiary">Tertiary</ion-button>
  <ion-button color="success">Success</ion-button>
  <ion-button color="warning">Warning</ion-button>
  <ion-button color="danger">Danger</ion-button>
  <ion-button color="light">Light</ion-button>
  <ion-button color="medium">Medium</ion-button>
  <ion-button color="dark">Dark</ion-button>

  <!-- Expand -->
  <ion-button expand="full">Full Button</ion-button>
  <ion-button expand="block">Block Button</ion-button>

  <!-- Round -->
  <ion-button shape="round">Round Button</ion-button>

  <!-- Fill -->
  <ion-button expand="full" fill="outline">Outline + Full</ion-button>
  <ion-button expand="block" fill="outline">Outline + Block</ion-button>
  <ion-button shape="round" fill="outline">Outline + Round</ion-button>

  <!-- Icons -->
  <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>

  <!-- Sizes -->
  <ion-button size="large">Large</ion-button>
  <ion-button>Default</ion-button>
  <ion-button size="small">Small</ion-button>
</template>

<script>
import { IonButton } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
  components: { IonButton }
});
</script>

Properties


buttonType

Description

The type of button.

Attributebutton-type
Typestring
Default'button'

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.

Attributecolor
Typestring | undefined

disabled

Description

If true, the user cannot interact with the button.

Attributedisabled
Typeboolean
Defaultfalse

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).

Attributedownload
Typestring | undefined

expand

Description

Set to "block" for a full-width button or to "full" for a full-width button without left and right borders.

Attributeexpand
Type"block" | "full" | undefined

fill

Description

Set to "clear" for a transparent button, to "outline" for a transparent button with a border, or to "solid". The default style is "solid" except inside of a toolbar, where the default is "clear".

Attributefill
Type"clear" | "default" | "outline" | "solid" | 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.

Attributehref
Typestring | undefined

mode

Description

The mode determines which platform styles to use.

Attributemode
Type"ios" | "md"

rel

Description

Specifies the relationship of the target object to the link object. The value is a space-separated list of link types.

Attributerel
Typestring | undefined

routerAnimation

Description

When using a router, it specifies the transition animation when navigating to another page using href.

Type((baseEl: any, opts?: any) => Animation) | undefined

routerDirection

Description

When using a router, it specifies the transition direction when navigating to another page using href.

Attributerouter-direction
Type"back" | "forward" | "root"
Default'forward'

shape

Description

The button shape.

Attributeshape
Type"round" | undefined

size

Description

The button size.

Attributesize
Type"default" | "large" | "small" | undefined

strong

Description

If true, activates a button with a heavier font weight.

Attributestrong
Typeboolean
Defaultfalse

target

Description

Specifies where to display the linked URL. Only applies when an href is provided. Special keywords: "_blank""_self""_parent""_top".

Attributetarget
Typestring | undefined

type

Description

The type of the button.

Attributetype
Type"button" | "reset" | "submit"
Default'button'

Events


NameDescription
ionBlurEmitted when the button loses focus.
ionFocusEmitted when the button has focus.

CSS Shadow Part

NameDescription
nativeThe native HTML button or anchor element that wraps all child elements.

CSS Custom Properties

NameDescription
--backgroundBackground of the button
--background-activatedBackground of the button when pressed. Note: setting this will interfere with the Material Design ripple.
--background-activated-opacityOpacity of the button when pressed
--background-focusedBackground of the button when focused with the tab key
--background-focused-opacityOpacity of the button when focused with the tab key
--background-hoverBackground of the button on hover
--background-hover-opacityOpacity of the background on hover
--border-colorBorder color of the button
--border-radiusBorder radius of the button
--border-styleBorder style of the button
--border-widthBorder width of the button
--box-shadowBox shadow of the button
--colorText color of the button
--color-activatedText color of the button when pressed
--color-focusedText color of the button when focused with the tab key
--color-hoverText color of the button when hover
--opacityOpacity of the button
--padding-bottomBottom padding of the button
--padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-topTop padding of the button
--ripple-colorColor of the button ripple effect
--transitionTransition of the button

Slots


NameDescription
Content is placed between the named slots if provided without a slot.
"end"Content is placed to the right of the button text in LTR, and to the left in RTL.
"icon-only"Should be used on an icon in a button that has no text.
"start"Content is placed to the left of the button text in LTR, and to the right in RTL.

Ion-ripple-effect

Thành phần hiệu ứng gợn thêm hiệu ứng tương tác gợn mực trong Material Design . Thành phần này chỉ có thể được sử dụng bên trong một <ion-app>và có thể được thêm vào bất kỳ thành phần nào.

Điều quan trọng cần lưu ý là cha mẹ nên có vị trí tương đối vì hiệu ứng gợn sóng được định vị tuyệt đối và sẽ bao phủ cha mẹ gần nhất với vị trí tương đối. Phần tử cha cũng nên được cung cấp cho ion-activatablelớp, lớp này cho biết hiệu ứng gợn sóng rằng phần tử có thể nhấp được.

Loại mặc định "bounded", sẽ mở rộng hiệu ứng gợn sóng từ vị trí nhấp chuột ra ngoài. Để thêm hiệu ứng gợn sóng luôn bắt đầu ở trung tâm của phần tử và mở rộng trong một vòng tròn, hãy thêm một "unbounded"loại. Bạn nên thêm overflow: hiddenvào phần tử mẹ để tránh gợn sóng tràn vùng chứa của nó, đặc biệt là với một gợn sóng không bị ràng buộc.

Usage

<ion-app>
  <ion-content>
    <div class="ion-activatable ripple-parent">
      A plain div with a bounded ripple effect
      <ion-ripple-effect></ion-ripple-effect>
    </div>

    <button class="ion-activatable ripple-parent">
      A button with a bounded ripple effect
      <ion-ripple-effect></ion-ripple-effect>
    </button>

    <div class="ion-activatable ripple-parent">
      A plain div with an unbounded ripple effect
      <ion-ripple-effect type="unbounded"></ion-ripple-effect>
    </div>

    <button class="ion-activatable ripple-parent">
      A button with an unbounded ripple effect
      <ion-ripple-effect type="unbounded"></ion-ripple-effect>
    </button>
  </ion-content>
</ion-app>
CopyCopied
.ripple-parent {
  position: relative;
  overflow: hidden;
}
<ion-app>
  <ion-content>
    <div class="ion-activatable ripple-parent">
      A plain div with a bounded ripple effect
      <ion-ripple-effect></ion-ripple-effect>
    </div>

    <button class="ion-activatable ripple-parent">
      A button with a bounded ripple effect
      <ion-ripple-effect></ion-ripple-effect>
    </button>

    <div class="ion-activatable ripple-parent">
      A plain div with an unbounded ripple effect
      <ion-ripple-effect type="unbounded"></ion-ripple-effect>
    </div>

    <button class="ion-activatable ripple-parent">
      A button with an unbounded ripple effect
      <ion-ripple-effect type="unbounded"></ion-ripple-effect>
    </button>
  </ion-content>
</ion-app>
CopyCopied
.ripple-parent {
  position: relative;
  overflow: hidden;
}

import { Component, h } from '@stencil/core';

@Component({
  tag: 'ripple-effect-example',
  styleUrl: 'ripple-effect-example.css'
})
export class RippleEffectExample {
  render() {
    return [
      <ion-app>
        <ion-content>
          <div class="ion-activatable ripple-parent">
            A plain div with a bounded ripple effect
            <ion-ripple-effect></ion-ripple-effect>
          </div>

          <button class="ion-activatable ripple-parent">
            A button with a bounded ripple effect
            <ion-ripple-effect></ion-ripple-effect>
          </button>

          <div class="ion-activatable ripple-parent">
            A plain div with an unbounded ripple effect
            <ion-ripple-effect type="unbounded"></ion-ripple-effect>
          </div>

          <button class="ion-activatable ripple-parent">
            A button with an unbounded ripple effect
            <ion-ripple-effect type="unbounded"></ion-ripple-effect>
          </button>
        </ion-content>
      </ion-app>
    ];
  }
}
CopyCopied
.ripple-parent {
  position: relative;
  overflow: hidden;
}


import React from 'react';
import { IonApp, IonContent, IonRippleEffect } from '@ionic/react';
import './RippleEffectExample.css';

export const RippleExample: React.FC = () => (
  <IonApp>
   <IonContent>
      <div className="ion-activatable ripple-parent">
        A plain div with a bounded ripple effect
        <IonRippleEffect></IonRippleEffect>
      </div>

      <button className="ion-activatable ripple-parent">
        A button with a bounded ripple effect
        <IonRippleEffect></IonRippleEffect>
      </button>

      <div className="ion-activatable ripple-parent">
        A plain div with an unbounded ripple effect
        <IonRippleEffect type="unbounded"></IonRippleEffect>
      </div>

      <button className="ion-activatable ripple-parent">
        A button with an unbounded ripple effect
        <IonRippleEffect type="unbounded"></IonRippleEffect>
      </button>
    </IonContent>
  </IonApp>
);
CopyCopied
.ripple-parent {
  position: relative;
  overflow: hidden;
}

Properties

type

Description

Đặt loại hiệu ứng gợn sóng:

  • bounded: hiệu ứng gợn sóng mở rộng từ vị trí nhấp chuột của người dùng
  • unbounded: hiệu ứng gợn sóng mở rộng từ tâm của nút và tràn vùng chứa.

LƯU Ý: Các bề mặt cho gợn sóng có giới hạn phải đặt thuộc tính tràn thành ẩn, trong khi các bề mặt cho gợn sóng không giới hạn phải đặt thuộc tính hiển thị.

Attributetype
Type"bounded" | "unbounded"
Default'bounded'

Methods

addRipple

Description

Adds the ripple effect to the parent element.

SignatureaddRipple(x: number, y: number) => Promise<() => void>



Đăng nhận xét

0 Nhận xét

myadcash