@pikas-ui/switch

This package contains a switch component that can be used to toggle between two states.

This library is based on Radix Ui.

Change Log

Requirements

To use this package, you must install the @pikas-ui/styles package.

Installation

You can install this package using npm, yarn, or pnpm.

npm install @pikas-ui/switch
yarn add @pikas-ui/switch
pnpm add @pikas-ui/switch

Usage

Switch

The switch component is used to toggle between two states.

import { Switch } from '@pikas-ui/switch';

const Example: React.FC = () => {
  return <Switch label="Switch label" id="switch" />;
};

Props

Props extends ButtonHTMLAttributes<HTMLButtonElement>

PropDescriptionTypeDefault
idThe id of the switch.string-
labelThe label of the switch.string or ReactNode-
nameThe name of the switch.string-
fontSizeThe font size of the switch.string-
textErrorThe text error of the switch.string-
onCheckedChangeThe callback function when the switch is changed.(val: boolean) => void-
defaultCheckedThe default checked value of the switch.booleanfalse
cssThe css of the switch.SwitchCSS-
disabledThe disabled value of the switch.booleanfalse
sideThe side of the switch."left' or 'right""left"
IconsThe icons of the switch.{ checked: FC<IconProps>, unchecked: FC<IconProps> }-

Contributing

This documentation can be edited on GitHub here