Carbon Flutter
  • Overview ⚡️
  • Installation ⚙️
  • Widgets 🧩
    • Breadcrumb
    • Button
    • Checkbox
    • Form
    • Icons
    • Link
    • Notification
    • OverflowMenu
    • Text
    • TextField
    • Toggle
Powered by GitBook
On this page
  • Overview
  • Widget API
  • Example

Was this helpful?

  1. Widgets 🧩

Toggle

PreviousTextField

Last updated 2 years ago

Was this helpful?

Overview

A toggle is used to quickly switch between two possible states. They are commonly used for “on/off” switches.

Widget API

Property
Description

onToggle

Called when the value of the toggle change. This callback passes the new value, but doesn't update its state internally.

  • Type: void Function(bool value)

  • Default: required

enable

Whether the toggle is enabled or not.

  • Type: bool

  • Default: true

value

Whether the initial value of the toggle is checked or not.

  • Type: bool

  • Default: true

labelText

The labelText of this toggle.

  • Type: String?

  • Default: optional

size

The size of this toggle. It can be md or sm.

  • Type: CToggleSize

  • Default: CToggleSize.md

showStatusLabel

Whether the toggle should display its status (On | Off) or not.

  • Type: bool

  • Default: true

Example

CToggle(
  onToggle: (v) {},
  value: true,
  labelText: 'Label text',
  showStatusLabel: true,
  size: CToggleSize.sm,
)