UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

8bitcn/8-bit Switch

Inputs & forms
1 of 3
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

3 versions·3 librariesCompare all switches →

  • 8bitcn
  • Kokonut UI
  • shadcn/ui

8-bit Switch

A simple 8-bit switch component

npx shadcn@latest add https://www.8bitcn.com/r/switch.json
Open in v0 Docs Repo
Library
8bitcn
License
MIT
Stack
React · Tailwind CSS · radix
Packages
cnradix-ui
Also adds
switch
Size
59 lines

Code

components/ui/8bit/switch.tsx

"use client";

import type * as React from "react";

import * as SwitchPrimitive from "@radix-ui/react-switch";

import { cn } from "@/lib/utils";

function Switch({
  className,
  ...props
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
  return (
    <SwitchPrimitive.Root
      data-slot="switch"
      className={cn(
        "relative peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-4 w-8 shrink-0 items-center border border-transparent shadow-xs transition-all outline-none border-none disabled:cursor-not-allowed disabled:opacity-50",
        className
      )}
      {...props}
    >
      <SwitchPrimitive.Thumb
        data-slot="switch-thumb"
        className={cn(
          "bg-primary data-[state=checked]:bg-primary-foreground dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 data-[state=checked]:border-l data-[state=unchecked]:border-r border-foreground dark:border-ring ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%)] data-[state=unchecked]:translate-x-0"
        )}
      />

      <div
        className="absolute inset-0 border-y-4 -my-1 border-foreground dark:border-ring pointer-events-none"
        aria-hidden="true"
      />

      <div
        className="absolute inset-0 border-x-4 -mx-1 border-foreground dark:border-ring pointer-events-none"
        aria-hidden="true"
      />
    </SwitchPrimitive.Root>
  );
}

export { Switch };

More like this

8-bit Checkbox

8bitcn·Inputs & forms

8-bit Avatar

8bitcn·Media & 3D

Holo Card

React Bits·CardsMIT+

Slider

shadcn/ui·Inputs & forms

Input Otp

shadcn/ui·Inputs & forms

Toolbar Dynamic

Motion Primitives·Navigation

Ai Message

SmoothUI·Backgrounds

Ai Reasoning

SmoothUI·Media & 3D

Skeleton

shadcn/ui·Feedback & loaders

Bubble Menu

React Bits·BackgroundsMIT+

Family Button

Cult UI·Buttons

Sidebar

shadcn/ui·Navigation

Progress

shadcn/ui·Feedback & loaders

Sheet

shadcn/ui·Overlays

8-bit Slider

8bitcn·Inputs & forms