Button

Overview

Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.

Widget API

PropertyDescription

onTap

Called when the button is tapped.

  • Type: VoidCallback

  • Default: required

label

A text to display in the button.

  • Type: String

  • Default: required

enable

Whether the toggle is enabled or not.

  • Type: bool

  • Default: true

kind

The kind that the button represents. It can be primary, secondary, danger, tertiary, ghost.

  • Type: CButtonKind

  • Default: CButtonKind.primary

size

The size of this button. It can be regular, sm, md.

  • Type: CToggleSize

  • Default: CToggleSize.regular

icon

An optional icon to display in the button.

  • Type: Widget?

  • Default: optional

expand

Whether the button should fill the available width.

  • Type: bool

  • Default: false

labelSize

The size (in logical pixels) to use when painting the label.

  • Type: double

  • Default: 14.0

Example

CButton(
  label: 'Carbon Button',
  kind: CButtonKind.danger,
  icon: CIcon(CIcons.add, size: 16),
  size: CButtonSize.md,
  onTap: () {},
);

CButton.icon(
  kind: CButtonKind.danger,
  icon: CIcon(CIcons.add, size: 16),
  size: CButtonSize.md,
  onTap: () {},
);

Last updated