logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • Components Overview
  • General
    • Button
    • FloatButtonNew
    • Icon
    • Typography
  • Layout
    • Divider
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPickerNew
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCodeNew
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • TourNew
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • AppNew
    • ConfigProvider
When To Use
Examples
Basic
Disabled
Text & icon
Two sizes
Loading
API
Methods
Design Token

Switch

  • SliderTimePicker

    Resources

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    ahooks-React Hooks Library
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Namu Design Community

    Switching Selector.

    When To Use

    • If you need to represent the switching between two states or on-off state.
    • The difference between Switch and Checkbox is that Switch will trigger a state change directly when you toggle it, while Checkbox is generally used for state marking, which should work in conjunction with submit operation.

    Examples

    Basic

    The most basic usage.

    expand codeexpand code
    Text & icon

    With text and icon.

    expand codeexpand code
    Loading

    Mark a pending state of switch.

    expand codeexpand code
    Disabled

    Disabled state of Switch.

    expand codeexpand code
    Two sizes

    size="small" represents a small sized switch.

    expand codeexpand code

    API

    Common props ref:Common props

    PropertyDescriptionTypeDefault
    autoFocusWhether get focus when component mountedbooleanfalse
    checkedDetermine whether the Switch is checkedbooleanfalse
    checkedChildrenThe content to be shown when the state is checkedReactNode-
    classNameThe additional class to Switchstring-
    defaultCheckedWhether to set the initial statebooleanfalse
    disabledDisable switchbooleanfalse
    loadingLoading state of switchbooleanfalse
    sizeThe size of the Switch, options: default smallstringdefault
    unCheckedChildrenThe content to be shown when the state is uncheckedReactNode-
    onChangeTrigger when the checked state is changingfunction(checked: boolean, event: Event)-
    onClickTrigger when clickedfunction(checked: boolean, event: Event)-

    Methods

    NameDescription
    blur()Remove focus
    focus()Get focus

    Design Token

    Global Token