BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/@nivalis/ui/switch

Switch

nivalis-ui/switch
FreeComponent

A switch component.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/nivalis-studio/nivalis-ui/main/public/r/switch.json

Source

registry/niv/ui/switch.tsxraw.githubusercontent.com/nivalis-studio/nivalis-ui/main/public/r/switch.json
1'use client';
2
3import { Root, Thumb } from '@radix-ui/react-switch';
4import { cn } from '@/lib/classnames';
5import type * as React from 'react';
6
7function Switch({ className, ...props }: React.ComponentProps<typeof Root>) {
8 return (
9 <Root
10 className={cn(
11 'peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs outline-none transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80',
12 className,
13 )}
14 data-slot='switch'
15 {...props}
16 >
17 <Thumb
18 className={cn(
19 'pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground',
20 )}
21 data-slot='switch-thumb'
22 />
23 </Root>
24 );
25}
26
27export { Switch };

What it pulls in

npm packages

  • @radix-ui/react-switch

Files it writes

  • registry/niv/ui/switch.tsx

Facts

Registry
@nivalis/ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-02
Last confirmed
2 days ago

Go to the source

ui.nivalis.studio nivalis-studio/nivalis-ui on GitHub Raw registry item This item as JSON

More from @nivalis/ui

All 23 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordion@nivalis/uiComponentsFree1 dep
Avataravatar@nivalis/uiComponentsFree1 dep
Badgebadge@nivalis/uiComponentsFreeno deps
Breadcrumbbreadcrumb@nivalis/uiComponentsFree1 dep
Buttonbutton@nivalis/uiComponentsFree1 dep
Cardcard@nivalis/uiComponentsFreeno deps
Checkboxcheckbox@nivalis/uiComponentsFree1 dep
Commandcommand@nivalis/uiComponentsFree2 deps · 2 files
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