GSFab

The Floating Action Button (FAB) is a dynamic button that stays visible and provides access to a primary action throughout the user's journey in the application. It is a powerful UI element that adds a touch of elegance and convenience to the user experience.
API Reference
This is an illustration of a Themed GSFab widget with default configuration.

    import 'package:gluestack_ui/gluestack_ui.dart';

    GSCenter(
      child: Stack(
        children: [
          GSBox(
            style: GSStyle(
              height: 360,
              width: 320,
              borderRadius: $GSRadii.$md,
              bg: $GSColors.backgroundLight50,
              dark: GSStyle(color: $GSColors.backgroundDark900),
            ),
          ),
          GSFab(
            size: GSFABSizes.$md,
            placement: GSFABPlacements.bottomRight,
            onPressed: () {},
            isDisabled: false,
            isHovered: false,
            isPressed: false,
            icon: const GSFabIcon(icon: Icons.add),
            label: const GSFabLabel(text: 'Quick Start'),
          ),
        ],
      ),
    )


API Reference

Import

To use this widget in your project, include the following import statement in your file.
import "package:gluestack_ui/gluestack_ui.dart"

Widget Parameters

This section provides a comprehensive reference list for the widget parameters, detailing descriptions, properties, types, and default behavior for easy project integration.

GSFab

Contains all fab related layout style properties and actions. It inherits all the properties of Flutter's ElevatedButton widget.
Prop
Type
Default
Description
placement
"topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "topCenter" | "bottomCenter"
"bottomRight"
Placement of the Fab
isHovered
bool
false
To manually set hover to the fab.
isPressed
bool
false
To manually set pressable state to the fab.
isDisabled
bool
false
To manually set disable to the fab.

GSFabLabel

Contains all text related layout style properties and actions. It inherits all the properties of Flutter's Text widget.

GSFabIcon

Contains all Icon related layout style properties and actions. It inherits all the properties of Flutter's Icon widget.

Features

  • Keyboard support for actions.
  • Support for hover, focus and active states.
  • Option to add your styles or use the default styles.

Accessibility

We have outlined the various features that ensure the GSFab widget is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards. Adheres to the WAI-ARIA design pattern

Keyboard

  • Tab: Moves focus to the next focusable element.
  • Shift + Tab: Moves focus to the previous focusable element.
  • Enter: Triggers the fab's action.

Screen Reader

  • VoiceOver: When the fab is focused, the screen reader will announce the fab's label and its current state.

Parameters

GSFab widget is created using ElevatedButton widget from flutter. It extends all the properties supported by Flutter ElevatedButton and additionally the properties mentioned below.

GSFab

Name
Value
Default
size
sm | md | lg
md
placement
topRight | topLeft | bottomRight | bottomLeft | topCenter | bottomCenter
bottom right
Note: These properties are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these properties may not be available.

Examples

The Examples section provides visual representations of the different variants of the widget, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

GSFab with Icon

A GSFab widget with an icon adds a visually striking and easily recognizable button that triggers a specific action or function within a user interface.

    import 'package:gluestack_ui/gluestack_ui.dart';

    GSCenter(
      child: Stack(
        children: [
          GSBox(
            style: GSStyle(
              height: 360,
              width: 320,
              borderRadius: $GSRadii.$md,
              bg: $GSColors.trueGray800,
              padding: const EdgeInsets.all(20),
            ),
            child: GSVStack(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Kevin James'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Kevin James'),
                        GSText(text: 'Tech Lead'),
                      ],
                    )
                  ],
                ),
                const SizedBox(
                  height: 20,
                ),
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1527980965255-d3b416303d12?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1180&q=80',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Jacob Jones'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Jacob Jones'),
                        GSText(text: 'Manager'),
                      ],
                    )
                  ],
                ),
                const SizedBox(
                  height: 20,
                ),
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1599566150163-29194dcaad36?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Albert Flores'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Albert Flores'),
                        GSText(text: 'HR'),
                      ],
                    )
                  ],
                ),
              ],
            ),
          ),
          GSFab(
            onPressed: () {},
            icon: GSFabIcon(
              icon: Icons.edit_square,
              style: GSStyle(color: $GSColors.white),
            ),
          ),
        ],
      ),
    )

GSFab with Icon and Text

A GSFab widget with an icon and text combines a visual icon with accompanying text to create a prominent and descriptive button that triggers a specific action or function within a user interface.

    import 'package:gluestack_ui/gluestack_ui.dart';

    GSCenter(
      child: Stack(
        children: [
          GSBox(
            style: GSStyle(
              height: 360,
              width: 320,
              borderRadius: $GSRadii.$md,
              bg: $GSColors.trueGray800,
              padding: const EdgeInsets.all(20),
            ),
            child: GSVStack(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Kevin James'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Kevin James'),
                        GSText(text: 'Tech Lead'),
                      ],
                    )
                  ],
                ),
                const SizedBox(
                  height: 20,
                ),
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1527980965255-d3b416303d12?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1180&q=80',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Jacob Jones'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Jacob Jones'),
                        GSText(text: 'Manager'),
                      ],
                    )
                  ],
                ),
                const SizedBox(
                  height: 20,
                ),
                GSHStack(
                  children: [
                    GSAvatar(
                      avatarImage: const GSImage(
                        path: 'https://images.unsplash.com/photo-1599566150163-29194dcaad36?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80',
                        imageType: GSImageType.network,
                      ),
                      style: GSStyle(
                        bg: Colors.orange,
                        textStyle: const TextStyle(color: Colors.white),
                      ),
                      fallBackText: const GSAvatarFallBackText('Albert Flores'),
                    ),
                    const SizedBox(
                      width: 10,
                    ),
                    const GSVStack(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        GSHeading(text: 'Albert Flores'),
                        GSText(text: 'HR'),
                      ],
                    )
                  ],
                ),
              ],
            ),
          ),
          GSFab(
            onPressed: () {},
            icon: GSFabIcon(
              icon: Icons.edit_square,
              style: GSStyle(color: $GSColors.white),
            ),
          ),
        ],
      ),
    )

Placement

A GSFab widget with placement options allows for flexible positioning of the button within a user interface, enabling convenient and intuitive access to key actions or functionalities in various locations.

    import 'package:gluestack_ui/gluestack_ui.dart';

    GSCenter(
      child: Stack(
        children: [
          GSBox(
            style: GSStyle(
              height: 300,
              width: 450,
              borderRadius: $GSRadii.$md,
              bg: $GSColors.trueGray800,
              padding: const EdgeInsets.all(20),
            ),
            child: GSVStack(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                GSCheckBox(
                  icon: GSCheckBoxIndicator(
                    style: GSStyle(
                      margin: EdgeInsets.only(
                        right: $GSSpace.$4,
                        bottom: $GSSpace.$4,
                      ),
                    ),
                    child: const GSCheckBoxIcon(),
                  ),
                  value: "Design",
                  onChanged: (value) {},
                  label: const GSVStack(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      GSCheckBoxLabel(text: "Design"),
                      GSText(
                        text: 'Subscribe to updates from the Design Feed',
                      ),
                    ],
                  ),
                ),
                const SizedBox(
                  height: 20,
                ),
                GSCheckBox(
                  icon: GSCheckBoxIndicator(
                    style: GSStyle(
                      margin: EdgeInsets.only(
                        right: $GSSpace.$4,
                        bottom: $GSSpace.$4,
                      ),
                    ),
                    child: const GSCheckBoxIcon(),
                  ),
                  value: "Marketing",
                  onChanged: (value) {},
                  label: const GSVStack(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      GSCheckBoxLabel(text: "Marketing"),
                      GSText(
                        text: 'Subscribe to updates from the Marketing Feed',
                      ),
                    ],
                  ),
                ),
                const SizedBox(
                  height: 20,
                ),
                GSCheckBox(
                  icon: GSCheckBoxIndicator(
                    style: GSStyle(
                      margin: EdgeInsets.only(
                        right: $GSSpace.$4,
                        bottom: $GSSpace.$4,
                      ),
                    ),
                    child: const GSCheckBoxIcon(),
                  ),
                  value: "Engineering",
                  onChanged: (value) {},
                  label: const GSVStack(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      GSCheckBoxLabel(text: "Engineering"),
                      GSText(
                        text: 'Subscribe to updates from the Engineering Feed',
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          GSFab(
            placement: GSPlacements.bottomCenter,
            onPressed: () {},
            icon: GSFabIcon(
              icon: Icons.add,
              style: GSStyle(color: $GSColors.white),
            ),
          ),
        ],
      ),
    )


Edit this page on GitHub