{ "slug": "switch", "mode": "scenarios", "examples": [ { "id": "switch-ex-1", "title": "默认与常用变体", "titleSrc": "demo", "desc": "", "html": "
\n
\n \n 启用通知\n
\n
", "preview": { "show": [ [ 0, 2 ] ], "hide": [ [ 1 ], [ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 2, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n \n 启用通知\n
", "jsx": "import { useState } from 'react';\nimport { KoleSwitch } from 'kole-ui/react';\n\nexport default function NotifySwitch() {\n const [notify, setNotify] = useState(true);\n return ;\n}", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { useState } from 'react';\nimport { KoleSwitch } from 'kole-ui/react';\n\ntype SwitchSize = 'large' | 'default' | 'small';\n\nexport default function NotifySwitch(): JSX.Element {\n const [notify, setNotify] = useState(true);\n const size: SwitchSize = 'default';\n\n return ;\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": "依据 frameworks/Switch.html:6 内联脚本(aria-checked / is-on 点击切换,默认开启)与 Switch.jsx:4 的 checked 默认值" }, { "id": "switch-ex-2", "title": "状态与使用场景", "titleSrc": "demo", "desc": "", "html": "
\n
\n
即时启停配置项或业务状态,例如启用通知、公开数据和自动同步。
\n 支持键盘焦点、状态反馈和令牌化样式。\n
\n

零运行时依赖;数据请求、权限和国际化由宿主接入方决定。

\n
", "preview": { "show": [ [ 0, 3 ] ], "hide": [ [ 1 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ], [ 0, 3, 0 ] ], "mode": "scenarios" }, "previewSafe": true, "previewUnsafeReasons": [], "source": "curated", "code": { "html": "
\n
即时启停配置项或业务状态,例如启用通知、公开数据和自动同步。
\n 支持键盘焦点、状态反馈和令牌化样式。\n
\n

零运行时依赖;数据请求、权限和国际化由宿主接入方决定。

", "jsx": "import { KoleSwitch } from 'kole-ui/react';\n\n
\n \n 支持键盘焦点、状态反馈和令牌化样式。\n
", "vue3": "\n\n", "vue2": "\n\n", "tsx": "import { KoleSwitch } from 'kole-ui/react';\n\ntype SwitchSize = 'large' | 'default' | 'small';\n\ninterface SurfaceState {\n checked: boolean;\n disabled: boolean;\n size: SwitchSize;\n hint: string;\n}\n\nconst state: SurfaceState = {\n checked: false,\n disabled: true,\n size: 'default',\n hint: '支持键盘焦点、状态反馈和令牌化样式。',\n};\n\nexport default function SwitchSurfaceDemo(): JSX.Element {\n return (\n
\n \n {state.hint}\n
\n );\n}", "vue3ts": "\n\n", "vue2ts": "\n\n" }, "notes": "依据 frameworks/Switch.html:6 第二块标记(kole-switch-surface 面板 + kole-switch-desc 说明文案)与 Switch.jsx:4 的 disabled / size" } ], "curated": true }