BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/scificn/switch

Switch

scificn/switch
FreeComponent

Toggle switch with ASCII bracket style [OFF]/[ON] display.

Live preview

live · rendered by the registry
Rendered by scificn on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://www.scificn.dev/r/switch.json

Source

ui/switch/switch.tsxwww.scificn.dev/r/switch.json
1import * as React from 'react'
2import * as SwitchPrimitive from '@radix-ui/react-switch'
3import { cn } from '@/lib/utils'
4
5export interface SwitchProps
6 extends React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root> {
7 label?: string
8}
9
10const Switch = React.forwardRef<
11 React.ElementRef<typeof SwitchPrimitive.Root>,
12 SwitchProps
13>(({ className, label, id, ...props }, ref) => {
14 const switchId = id ?? label?.toLowerCase().replace(/\s+/g, '-')
15
16 return (
17 <div style={{ display: 'inline-flex', alignItems: 'center', gap: '0.625rem' }}>
18 <SwitchPrimitive.Root
19 ref={ref}
20 id={switchId}
21 className={cn(
22 'peer inline-flex items-center shrink-0',
23 'h-6 w-14',
24 'rounded-none',
25 'border border-[var(--border)]',
26 'bg-[var(--surface)]',
27 'cursor-pointer',
28 'focus-visible:outline-none',
29 'focus-visible:border-[var(--border-active)]',
30 'focus-visible:shadow-[var(--glow-green)]',
31 'disabled:cursor-not-allowed disabled:opacity-40',
32 'data-[state=checked]:border-[var(--color-green)]',
33 'data-[state=checked]:shadow-[var(--glow-green)]',
34 'transition-all duration-150',
35 'font-mono text-[0.6rem] tracking-widest',
36 'relative overflow-hidden',
37 className
38 )}
39 {...props}
40 >
41 {/* OFF label */}
42 <span
43 className="absolute left-1.5 select-none"
44 style={{
45 color: 'var(--text-muted)',
46 letterSpacing: '0.04em',
47 fontSize: '0.6rem',
48 transition: 'opacity 0.15s',
49 }}
50 aria-hidden="true"
51 >
52 [OFF]
53 </span>
54
55 <SwitchPrimitive.Thumb asChild>
56 {/* Invisible thumb — state is conveyed via root styles + text */}
57 <span style={{ display: 'none' }} />
58 </SwitchPrimitive.Thumb>
59
60 {/* ON label — shows when checked via CSS */}
61 <span
62 className="absolute right-1.5 select-none peer-data-[state=unchecked]:opacity-0"
63 style={{
64 color: 'var(--color-green)',
65 textShadow: 'var(--text-glow-green)',
66 letterSpacing: '0.04em',
67 fontSize: '0.6rem',
68 transition: 'opacity 0.15s',
69 }}
70 aria-hidden="true"
71 >
72 [ON]
73 </span>
74 </SwitchPrimitive.Root>
75
76 {label && (
77 <label
78// … truncated

What it pulls in

npm packages

  • @radix-ui/react-switch

Facts

Registry
scificn
Type
registry:ui
Access
Free
Files written
0
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
today

Go to the source

Docs on scificn www.scificn.dev baxy5/scificn-ui on GitHub Raw registry item This item as JSON

More from scificn

All 33 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AlertalertscificnComponentsFree1 dep
BadgebadgescificnComponentsFree1 dep
Bar Chartbar-chartscificnComponentsFreeno deps
BreadcrumbbreadcrumbscificnComponentsFreeno deps
ButtonbuttonscificnComponentsFree2 deps
CardcardscificnComponentsFreeno deps
CheckboxcheckboxscificnComponentsFree1 dep
DialogdialogscificnComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex