DocsGitHub
Getting Started
  • Overview
  • Design Tokens
Components
  • Accordion
  • Alert
  • Announcement
  • Avatar
  • Badge
  • BigCalendar
  • Breadcrumb
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Checkbox
  • Chip
  • CloseButton
  • Combobox
  • CommandPalette
  • ContextMenu
  • Currency
  • DatePicker
  • DescriptionList
  • Drawer
  • DropdownMenu
  • EmptyState
  • Field
  • FileUpload
  • FormGrid
  • Hotkey
  • Icon
  • Input
  • Metric
  • Modal
  • MultiSelect
  • NumberInput
  • Pagination
  • Popover
  • ProgressBar
  • Radio
  • Rating
  • SegmentedControl
  • Select
  • SelectionCard
  • Sidebar
  • Skeleton
  • Slider
  • Spinner
  • Stepper
  • Switch
  • Table
  • Tabs
  • Textarea
  • Timeline
  • TimePicker
  • Toast
  • Tooltip
  • TransferList
  • TreeView
  • Wizard
Charts
  • Overview
  • Area Chart
  • Bar Chart
  • Donut Chart
  • Line Chart
  • Pie Chart
  • Stacked Bar Chart

Switch

A toggle control for switching between on and off states.

Installation

tsx
import { Switch } from "madagent";

Default

Sizes

With Description

Disable all wireless connections

Checked

Disabled

PropTypeDefaultDescription
label
ReactNode
-Label text displayed next to the switch
description
string
-Description text below the control
size
"sm""lg"
"sm"Switch size
disabled
boolean
falseDisables the switch
checked
boolean
-Controlled checked state
defaultChecked
boolean
-Initial checked state (uncontrolled)
onChange
(e: ChangeEvent) => void
-Called when the switch is toggled

RTL Support

Components automatically adapt to right-to-left languages using CSS logical properties.

Preview

تعطيل جميع الاتصالات اللاسلكية

Usage

tsx
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
  <Switch label="تفعيل الإشعارات" defaultChecked />
  <Switch label="الوضع المظلم" />
  <Switch label="وضع الطيران" description="تعطيل جميع الاتصالات اللاسلكية" />
</div>