Bài 18: Floating Action Button : Tìm hiểu ion-fab-button

Bài 18: Floating Action Button : Tìm hiểu ion-fab-button

  

ion-fab-button

Các nút hành động nổi (FAB) đại diện cho hành động chính trong một ứng dụng. Theo mặc định, chúng có hình tròn. Khi được nhấn, nút có thể mở thêm các thao tác liên quan. Như tên cho thấy, FAB thường nổi trên nội dung ở một vị trí cố định. Điều này không đạt được chỉ bằng cách sử dụng <ion-fab-button>FAB</ion-fab-button>. Chúng cần được bao bọc bằng một <ion-fab>thành phần để được cố định trên nội dung.

Nếu nút FAB không được bao bọc bằng <ion-fab>, nó sẽ cuộn theo nội dung. Các nút FAB có kích thước mặc định, kích thước nhỏ và có thể chấp nhận các màu khác nhau:

 Usage

<ion-content>

  <!-- Fixed Floating Action Button that does not scroll with the content -->
  <ion-fab slot="fixed">
    <ion-fab-button>Button</ion-fab-button>
  </ion-fab>

  <!-- Default Floating Action Button that scrolls with the content.-->
  <ion-fab-button>Default</ion-fab-button>

  <!-- Mini -->
  <ion-fab-button size="small">Mini</ion-fab-button>

  <!-- Colors -->
  <ion-fab-button color="primary">Primary</ion-fab-button>
  <ion-fab-button color="secondary">Secondary</ion-fab-button>
  <ion-fab-button color="danger">Danger</ion-fab-button>
  <ion-fab-button color="light">Light</ion-fab-button>
  <ion-fab-button color="dark">Dark</ion-fab-button>

</ion-content>


<ion-content>

  <!-- Fixed Floating Action Button that does not scroll with the content -->
  <ion-fab slot="fixed">
    <ion-fab-button>Button</ion-fab-button>
  </ion-fab>

  <!-- Default Floating Action Button that scrolls with the content.-->
  <ion-fab-button>Default</ion-fab-button>

  <!-- Mini -->
  <ion-fab-button size="small">Mini</ion-fab-button>

  <!-- Colors -->
  <ion-fab-button color="primary">Primary</ion-fab-button>
  <ion-fab-button color="secondary">Secondary</ion-fab-button>
  <ion-fab-button color="danger">Danger</ion-fab-button>
  <ion-fab-button color="light">Light</ion-fab-button>
  <ion-fab-button color="dark">Dark</ion-fab-button>

</ion-content>

<ion-content>

  <!-- Fixed Floating Action Button that does not scroll with the content -->
  <ion-fab slot="fixed">
    <ion-fab-button>Button</ion-fab-button>
  </ion-fab>

  <!-- Default Floating Action Button that scrolls with the content.-->
  <ion-fab-button>Default</ion-fab-button>

  <!-- Mini -->
  <ion-fab-button size="small">Mini</ion-fab-button>

  <!-- Colors -->
  <ion-fab-button color="primary">Primary</ion-fab-button>
  <ion-fab-button color="secondary">Secondary</ion-fab-button>
  <ion-fab-button color="danger">Danger</ion-fab-button>
  <ion-fab-button color="light">Light</ion-fab-button>
  <ion-fab-button color="dark">Dark</ion-fab-button>

</ion-content>

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

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

        {/* Fixed Floating Action Button that does not scroll with the content */}
        <ion-fab slot="fixed">
          <ion-fab-button>Button</ion-fab-button>
        </ion-fab>

        {/* Default Floating Action Button that scrolls with the content */}
        <ion-fab-button>Default</ion-fab-button>

        {/* Mini */}
        <ion-fab-button size="small">Mini</ion-fab-button>

        {/* Colors */}
        <ion-fab-button color="primary">Primary</ion-fab-button>
        <ion-fab-button color="secondary">Secondary</ion-fab-button>
        <ion-fab-button color="danger">Danger</ion-fab-button>
        <ion-fab-button color="light">Light</ion-fab-button>
        <ion-fab-button color="dark">Dark</ion-fab-button>

      </ion-content>
    ];
  }
}


<template>
  <ion-content>

    <!-- Fixed Floating Action Button that does not scroll with the content -->
    <ion-fab slot="fixed">
      <ion-fab-button>Button</ion-fab-button>
    </ion-fab>

    <!-- Default Floating Action Button that scrolls with the content.-->
    <ion-fab-button>Default</ion-fab-button>

    <!-- Mini -->
    <ion-fab-button size="small">Mini</ion-fab-button>

    <!-- Colors -->
    <ion-fab-button color="primary">Primary</ion-fab-button>
    <ion-fab-button color="secondary">Secondary</ion-fab-button>
    <ion-fab-button color="danger">Danger</ion-fab-button>
    <ion-fab-button color="light">Light</ion-fab-button>
    <ion-fab-button color="dark">Dark</ion-fab-button>

  </ion-content>
</template>

<script>
import { IonContent, IonFab, IonFabButton } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
  components: { IonContent, IonFab, IonFabButton }
});
</script>

Properties

activated

Description

If true, the fab button will be show a close icon.

Attributeactivated
Typeboolean
Defaultfalse

closeIcon

Description

The icon name to use for the close icon. This will appear when the fab button is pressed. Only applies if it is the main button inside of a fab containing a fab list.

Attributeclose-icon
Typestring
Default'close'

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 fab 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

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'

show

Description

If true, the fab button will show when in a fab-list.

Attributeshow
Typeboolean
Defaultfalse

size

Description

The size of the button. Set this to small in order to have a mini fab button.

Attributesize
Type"small" | undefined

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

translucent

Description

If true, the fab button will be translucent. Only applies when the mode is "ios" and the device supports backdrop-filter.

Attributetranslucent
Typeboolean
Defaultfalse

type

Description

The type of the button.

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

Event

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

Css Shadow Parts

NameDescription
close-iconThe close icon that is displayed when a fab list opens (uses ion-icon).
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 background when pressed
--background-focusedBackground of the button when focused with the tab key
--background-focused-opacityOpacity of the button background when focused with the tab key
--background-hoverBackground of the button on hover
--background-hover-opacityOpacity of the button 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
--close-icon-font-sizeFont size of the close icon
--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 on hover
--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

Đăng nhận xét

0 Nhận xét

myadcash