Search results

FabComponent API in React Floating Action Button API component

FabComponent represents the react Fab Component.

<FabComponent></FabComponent>

Properties

content

string

Defines the text content of the Button element.

    import { render } from "react-dom";
    import "./index.css";
    import * as React from "react";
    import { ButtonComponent } from "@syncfusion/ej2-react-buttons";
    import { SampleBase } from "./sample-base";

    export class Default extends SampleBase {
        content = "Normal";
  
        render() {
            return (
            <ButtonComponent cssClass="e-primary" content={this.content}></ButtonComponent>
        );}
    }

    render(<Default />, document.getElementById("sample"));

Defaults to ""

cssClass

string

Defines class/multiple classes separated by a space in the Button element. The Button types, styles, and size can be defined by using this.

    import { render } from "react-dom";
    import "./index.css";
    import * as React from "react";
    import { ButtonComponent } from "@syncfusion/ej2-react-buttons";
    import { SampleBase } from "./sample-base";

    export class Default extends SampleBase {
        primary_class = "e-primary";
  
        render() {
            return (
            <ButtonComponent cssClass={this.primary_class} content="Normal"></ButtonComponent>
        );}
    }

    render(<Default />, document.getElementById("sample"));

Defaults to ""

disabled

boolean

Specifies a value that indicates whether the Button is disabled or not.

Defaults to false.

enableHtmlSanitizer

boolean

Defines whether to allow the cross-scripting site or not.

Defaults to false

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads.

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

iconCss

string

Defines class/multiple classes separated by a space for the Button that is used to include an icon. Buttons can also include font icon and sprite image.

Defaults to ""

iconPosition

string | IconPosition

Positions the icon before/after the text content in the Button. The possible values are:

  • Left: The icon will be positioned to the left of the text content.
  • Right: The icon will be positioned to the right of the text content.

Defaults to IconPosition.Left

isPrimary

boolean

Defines whether to apply primary style for FAB.

Defaults to true

isToggle

boolean

Makes the Button toggle, when set to true. When you click it, the state changes from normal to active.

Defaults to false

position

string | FabPosition

Defines the position of the FAB relative to target. The possible values are:

  • TopLeft: Positions the FAB at the target’s top left corner.
  • TopCenter: Positions the FAB at the target’s top left corner.
  • TopRight: Positions the FAB at the target’s top left corner.
  • MiddleLeft: Positions the FAB at the target’s top left corner.
  • MiddleCenter: Positions the FAB at the target’s top left corner.
  • MiddleRight: Positions the FAB at the target’s top left corner.
  • BottomLeft: Positions the FAB at the target’s top left corner.
  • BottomCenter: Places the FAB on the bottom-center position of the target.
  • BottomRight: Positions the FAB at the target’s bottom right corner. To refresh the position of FAB on target resize, use refreshPosition method. The position will be refreshed automatically when browser resized.

    import * as React from 'react';
    import './style.css';
    import { FabComponent } from '@syncfusion/ej2-react-buttons';

export default function App() { return (

); }

Defaults to *FabPosition.BottomRight*

<h3 class="doc-prop-wrapper" id="target" data-Path="target-target">
<a href="#target" aria-hidden="true" class="anchor">
<svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 
3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 
4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 
1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z">
</path>
</svg>
</a><span class='doc-prop-name'>target</span>

<span class="doc-prop-type"> `string` &#124;  `HTMLElement`
</span>

</h3>


Defines the selector that points to an element in which the FAB will be positioned.
By default, FAB is positioned based on viewport of browser.
The target element must have relative position, else FAB will get positioned based on the closest element which has relative position.

Defaults to *''*

<h3 class="doc-prop-wrapper" id="visible" data-Path="visible-visible">
<a href="#visible" aria-hidden="true" class="anchor">
<svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 
3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 
4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 
1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z">
</path>
</svg>
</a><span class='doc-prop-name'>visible</span>

<span class="doc-prop-type"> `boolean`
</span>

</h3>


Defines whether the fab is visible or hidden.

Defaults to *true.*

## Methods

### click

Click the button element
its native method

Returns *void*

### destroy

Destroys the FAB instance.

Returns *void*

### focusIn

Sets the focus to Button
its native method

Returns *void*

### getPersistData

Get the properties to be maintained in the persisted state.

Returns *string*

### refreshPosition

Refreshes the FAB position. You can call this method to re-position FAB when target is resized.

Returns *void*

## Events

<h3 class="doc-prop-wrapper" id="created" data-Path="created-created">
<a href="#created" aria-hidden="true" class="anchor">
<svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 
3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 
4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 
1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z">
</path>
</svg>
</a><span class='doc-prop-name'>created</span>

<span class="doc-prop-type">  `EmitType<Event>`
</span>

</h3>


Triggers once the component rendering is completed.