Switch
adn-ui/switchFreeComponent
A control that indicates whether a setting is on or off.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/switch.jsonSource
1"use client";23import "./switch.css";4import { Switch as BaseSwitch } from "@base-ui/react/switch";5import type React from "react";6import { cn } from "tailwind-variants";78import { SwitchContext, useSwitchContext } from "./switch.context";9import { switchVariants, type SwitchVariants } from "./switch.variants";1011export type SwitchProps = SwitchVariants & React.ComponentProps<typeof BaseSwitch.Root>;1213export const SwitchRoot = ({ children, className, size, ...props }: SwitchProps) => {14 const slots = switchVariants({ size });1516 return (17 <SwitchContext.Provider value={{ slots }}>18 <BaseSwitch.Root className={cn(slots.root(), className)} {...props}>19 {children}20 </BaseSwitch.Root>21 </SwitchContext.Provider>22 );23};2425export type SwitchThumbProps = React.ComponentProps<typeof BaseSwitch.Thumb>;2627export const SwitchThumb = ({ className, ...props }: SwitchThumbProps) => {28 const { slots } = useSwitchContext();29 return <BaseSwitch.Thumb className={cn(slots.thumb(), className)} {...props} />;30};
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Aspect Ratioaspect-ratio | adn-ui | Components | Free | 1 dep · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files |
