组件目录

Switch开关

在两个互斥状态间切换,适用于立即生效的设置。

npx https://kalos-ui-six.vercel.app/cli/kalos-ui-0.3.12.tgz add switch
MCP

安装

在项目根目录运行,安装源码。

npx https://kalos-ui-six.vercel.app/cli/kalos-ui-0.3.12.tgz add switch

使用

React
"use client";
import { useState } from "react";import { KalosSwitch } from "@/components/ui/kalos-switch";
export default function Example() {  const [enabled, setEnabled] = useState(true);
  return (    <KalosSwitch      label="消息通知"      checked={enabled}      onCheckedChange={setEnabled}    />  );}

API

属性类型默认值说明
labelstring—控件的可见标签
descriptionstring—仅在需要补充信息时显示
errorstring—校验错误;显示时替代说明并关联控件
checkedboolean—受控开关状态
defaultCheckedbooleanfalse初始状态
onCheckedChange(checked: boolean) => void—状态变化时调用
disabledbooleanfalse禁用开关

键盘操作

Space
切换开关
Tab
移动到下一个控件