Skip to main content

Button

A pressable button supporting labels, icons, loading states, and user-defined visual variants.

When to use it

Use a Button for the primary and secondary actions on a screen — submitting forms, confirming dialogs, triggering navigation. Use Button.icon for a square icon-only button.

Import

import 'package:catalyst_ui/catalyst_ui.dart';

Usage

Button(
label: const Text('Save'),
variant: ButtonVariant.primary,
onPressed: _handleSave,
)

Pass null for onPressed to disable the button.

Parameters

ParameterTypeDefaultDescription
labelWidgetrequiredThe primary content, typically a Text.
onPressedVoidCallback?requiredCalled when tapped. null disables.
leadingIconWidget?nullIcon placed left of the label.
trailingIconWidget?nullIcon placed right of the label.
loadingboolfalseShows a Spinner and ignores taps.
elevatedboolfalseAdds a drop shadow.
fullWidthboolfalseStretches to fill available width.
sizeButtonSizeButtonSize.largeHeight/padding/font-size preset.
variantButtonVariantButtonVariant.primaryVisual variant.
semanticsLabelString?nullAccessibility label.

Button.icon

A square icon-only constructor. Requires icon, onPressed, and semanticsLabel; also accepts loading, elevated, size, variant, and shape.

Sizes

ButtonSize values: link, small (44px), medium (48px), large (52px, default), extraLarge (60px).

Variants

Built-in ButtonVariant presets:

  • ButtonVariant.primary — solid brand fill; default call-to-action.
  • ButtonVariant.secondary — outlined on a surface background.
  • ButtonVariant.tertiary — subtle filled with a light border.
  • ButtonVariant.ghost — no background or border.
  • ButtonVariant.destructive — solid danger fill.
  • ButtonVariant.success — solid success fill.

Define your own by subclassing ButtonVariant and implementing resolve:

class OutlineButtonVariant extends ButtonVariant {
const OutlineButtonVariant();


ButtonVariantStyle resolve(ColorScheme cs) => ButtonVariantStyle(
foregroundColor: cs.brand,
borderColor: cs.brand,
);
}

See Variants & Tones for the full pattern.