• Getting Started
  • Components
  • Github
  • Go pro
energyGetting started
  • Introduction
dComponents
  • Button Components
  • Grid Components
  • Input Components
  • Layout Components
  • Toast Components
  • Widget Components
  • Alert
  • Badge
  • Breadcrumb
  • Callout
  • Card
  • Carousel
  • Charts
  • Collapse
  • CreateElement
  • DataTable
  • Dropdown
  • ElementCover
  • Embed
  • Fade
  • Form
  • Icon
  • Img
  • Jumbotron
  • Link
  • ListGroup
  • Media
  • Modal
  • Nav
  • Navbar
  • Pagination
  • Popover
  • Progress
  • Spinner
  • Switch
  • Tabs
  • Toggler
  • Tooltip

Switch

React switch component.


Usage

Example

Passed props: {}
Passed props: {"size":"sm"}
Passed props: {"size":"lg"}
Passed props: {"variant":"3d"}
Passed props: {"shape":"pill"}
Passed props: {"variant":"opposite"}
Passed props: {"variant":"outline","shape":"pill"}

Script


  const modes = [
        {},
        { size: 'sm'},
        { size: 'lg'},
        { variant: '3d' },
        { shape: 'pill' },
        { variant: 'opposite' },
        { variant: 'outline', shape:'pill' }
      ];
  const colors = ['primary', 'success', 'warning', 'danger', 'info', 'dark', 'light', 'secondary'];

  return (
    <>
      {modes.map((mode, index)=>{
        return (
          <div className="d-flex justify-content-between my-4" key={index}>
            Passed props: {JSON.stringify(mode)}
            {
              colors.map((color, key)=>{
                return (
                  <CSwitch
                    key={key}
                    color={color}
                    checked
                    value={color}
                    {...mode}
                  />
                )
              })
            }
          </div>
        )
      })}
    </>
  )
  


# Features

  • Many styles and sizes
  • Checkbox or radio input mode

# Switch API

NameRequiredTypeDefault Value
classNamestring
user classes for the main HTML tag
innerRef(object | Function | string)
ref to the main tag
size(lg | sm)
size of the switch, valid values: 'sm','lg'
shape(pill | square)
shape of the switch, valid values: 'square','pill'
variant(() | opposite | outline)
variant of the component, valid values: 'outline', 'opposite', '3d'
colorstring
background color of the component
labelOnstring
optionally set text labels on switch (you can pass one or both labels)
labelOffstring
optionally set text labels on switch (you can pass one or both labels)

  • Components
    • Usage
      • Features
      • API
CoreUI © 2020 creativeLabs.core-logo