29 lines · 1.1 KB · TypeScript
RawDownload
import { Switch as Kobalte } from "@kobalte/core/switch"import { Show, splitProps } from "solid-js"import type { ComponentProps, ParentProps } from "solid-js" export interface SwitchProps extends ParentProps<ComponentProps<typeof Kobalte>> {  hideLabel?: boolean  description?: string} export function Switch(props: SwitchProps) {  const [local, others] = splitProps(props, ["children", "class", "hideLabel", "description"])  return (    <Kobalte {...others} data-component="switch">      <Kobalte.Input data-slot="switch-input" />      <Show when={local.children}>        <Kobalte.Label data-slot="switch-label" classList={{ "sr-only": local.hideLabel }}>          {local.children}        </Kobalte.Label>      </Show>      <Show when={local.description}>        <Kobalte.Description data-slot="switch-description">{local.description}</Kobalte.Description>      </Show>      <Kobalte.ErrorMessage data-slot="switch-error" />      <Kobalte.Control data-slot="switch-control">        <Kobalte.Thumb data-slot="switch-thumb" />      </Kobalte.Control>    </Kobalte>  )}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t