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 |
| Attribute | activated |
| Type | boolean |
| Default | false |
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. |
| Attribute | close-icon |
| Type | string |
| Default | 'close' |
color | |
| Description | The color to use from your application's color palette. Default options are: |
| Attribute | color |
| Type | string | undefined |
disabled | |
| Description | If |
| 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 |
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 |
mode | |
| Description | The mode determines which platform styles to use. |
| Attribute | mode |
| 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. |
| Attribute | rel |
| Type | string | undefined |
routerAnimation | |
| Description | When using a router, it specifies the transition animation when navigating to another page using |
| Type | ((baseEl: any, opts?: any) => Animation) | undefined |
routerDirection | |
| Description | When using a router, it specifies the transition direction when navigating to another page using |
| Attribute | router-direction |
| Type | "back" | "forward" | "root" |
| Default | 'forward' |
show | |
| Description | If |
| Attribute | show |
| Type | boolean |
| Default | false |
size | |
| Description | The size of the button. Set this to |
| Attribute | size |
| Type | "small" | undefined |
target | |
| Description | Specifies where to display the linked URL. Only applies when an |
| Attribute | target |
| Type | string | undefined |
translucent | |
| Description | If |
| Attribute | translucent |
| Type | boolean |
| Default | false |
type | |
| Description | The type of the button. |
| Attribute | type |
| Type | "button" | "reset" | "submit" |
| Default | 'button' |
Event
| Name | Description |
|---|---|
ionBlur | Emitted when the button loses focus. |
ionFocus | Emitted when the button has focus. |
Css Shadow Parts
| Name | Description |
|---|---|
close-icon | The close icon that is displayed when a fab list opens (uses ion-icon). |
native | The native HTML button or anchor element that wraps all child elements. |
CSS Custom Properties
| Name | Description |
|---|---|
--background | Background of the button |
--background-activated | Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. |
--background-activated-opacity | Opacity of the button background when pressed |
--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 button background on hover |
--border-color | Border color of the button |
--border-radius | Border radius of the button |
--border-style | Border style of the button |
--border-width | Border width of the button |
--box-shadow | Box shadow of the button |
--close-icon-font-size | Font size of the close icon |
--color | Text color of the button |
--color-activated | Text color of the button when pressed |
--color-focused | Text color of the button when focused with the tab key |
--color-hover | Text color of the button on hover |
--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 |

0 Nhận xét