Liquid Glass Easy

Button

A lens shaped like a button, with a press that answers.

LiquidGlassButton is one lens around an icon-and-label row. Because it refracts what is behind it, it has the lens's requirement: on Skia and the web it needs an ancestor LiquidGlassView — without one it degrades to a frosted pill. On Impeller it works anywhere.

Dart
LiquidGlassButton(
  label: 'Continue',
  icon: Icons.arrow_forward_rounded,
  width: 220,
  touch: const LiquidGlassTouch(flex: LiquidGlassFlex.subtle()),
  onPressed: () => next(),
)
ParameterDefaultWhat it does
labelnullButton text. Ignored when child is set.
iconnullLeading icon.
onPressednullNull disables the button — it dims and stops taking a press.
width / heightnull / 48Size. Null width hugs the content.
childnullReplaces the icon-and-label row entirely — an avatar, two lines of text, an SvgPicture, a badge row. It never sizes the button.
touchnullGive it one and the glass gives under a press.
stylenullShape, tint, refraction.
foregroundColor, fontSize, fontWeight, iconSizenull, 16, w600, 20The label row, without reaching for a theme.

Your own content#

Pass a child and it replaces the row. It is centred inside the button's padding and clipped to the glass shape, and the button stays on its width/height so the lens geometry holds. A bare Icon or Text inside it inherits foregroundColor, fontSize, fontWeight and iconSize, so it matches the built-in row by default.

Dart
LiquidGlassButton(
  width: 260,
  height: 62,
  onPressed: () => switchAccount(),
  child: myAvatarRow,
)

Comments

Comments are GitHub Discussions — reply from either place.