Widgets

FloatingActionButton

FloatingActionButton

Floating action button helper exposed through fab.

Example

fab(
  icon: "add",
  content: "Create",
  on_click: ->(_e) { page.update(status, value: "Create pressed") }
)

Common properties

  • positional content: fab("Create")
  • icon
  • content
  • url
  • on_click

Usage

count = 0
count_text = text(count.to_s, style: {size: 40})

page.add(
  container(
    expand: true,
    alignment: Ruflet::MainAxisAlignment::CENTER,
    content: count_text
  ),
  floating_action_button: fab(
    icon: "add",
    on_click: ->(_e) do
      count += 1
      page.update(count_text, value: count.to_s)
    end
  )
)

Supported forms

  • fab("Create")
  • fab(icon: "add")
  • fab(icon: "add", content: "Create")
  • fab(icon: Ruflet::MaterialIcons::ADD)
  • Use url: to open a link through the client url_launcher; use on_click:

for application actions.

Complete API

Helpers

  • fab(content = ..., **props)
  • floating_action_button(**props)
  • floatingactionbutton(**props)

Accepted properties

  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • aspect_ratio — Width-to-height ratio to maintain.
  • autofocus — Requests focus when first shown.
  • badge — Badge drawn on the corner of the control.
  • bgcolor — Background color.
  • bottom — Bottom offset when positioned inside a stack.
  • clip_behavior — How content overflowing the bounds is clipped.
  • col — Responsive column span (1-12) per breakpoint.
  • content — The single child control rendered inside this control.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • disabled_elevation — Sets the disabled elevation property.
  • elevation — Shadow depth (z-height).
  • enable_feedback — Plays touch feedback (sound/haptic) on interaction.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • focus_color — Color shown while focused.
  • focus_elevation — Sets the focus elevation property.
  • foreground_color — Foreground color.
  • height — Fixed height in logical pixels.
  • highlight_elevation — Sets the highlight elevation property.
  • hover_color — Color shown while hovered.
  • hover_elevation — Sets the hover elevation property.
  • icon — Icon name shown by the control.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • mini — Sets the mini property.
  • mouse_cursor — Cursor shown when hovering the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • shape — Shape/border of the control.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • splash_color — Splash color.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • url — URL the control loads or links to.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_click — Fired when the control is clicked/tapped.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: materials
  • Widget type: floatingactionbutton