Widgets

Card

Card

A material card — an elevated, rounded surface that groups related content.

Example

card(
  elevation: 2,
  content: container(
    padding: 16,
    content: column(
      spacing: 8,
      children: [
        text(value: "Monthly report", style: { size: 18, weight: "w700" }),
        text("Revenue is up 12% over last month."),
        filled_button(content: text("Open"), on_click: ->(_e) { open_report })
      ]
    )
  )
)

Common properties

  • content — the card's child control
  • elevation
  • bgcolor
  • shape
  • shadow_color
  • clip_behavior
  • margin
  • variant"elevated", "filled", or "outlined"

Usage

A card wraps a single content control — compose a column/row inside it for multiple children, and pad with a container for inner spacing.

Complete API

Helpers

  • card(content = ..., **props)

Accepted properties

  • adaptive — Adapts to the platform (Material/Cupertino) when true.
  • 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.
  • 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.
  • elevation — Shadow depth (z-height).
  • 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.
  • height — Fixed height in logical pixels.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around 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.
  • semantic_container — Sets the semantic container property.
  • shadow_color — Color of the drop shadow.
  • shape — Shape/border of the control.
  • show_border_on_foreground — Sets the show border on foreground property.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • variant — Sets the variant property.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: materials
  • Widget type: card