Refined UI

An opinionated, customizable superset of shadcn/ui

AgentsPrimitivesSkillsSkins
Guides
  • Overview
  • Get started
  • Shadcn compatibility
  • Architecture
  • Agent surface
Agents
  • Action Bar
  • Audio Recorder
  • Audio VisualizerBetaBeta — the props contract is close to final, but small breaking changes can still land.
  • Chat Input
  • Chat Input Attachment
  • Chat Message
  • Chat Scene
  • Code Block Editor
  • Dynamic NotificationExpExperimental — the contract and the rendering can change without notice. Own the installed copy before shipping it.
  • Environment Variables
  • Inline Attachment
  • Markdown Block
  • Task List
  • Thread Rail
  • Tool Call
  • User Ask
Blocks
  • Chat
  • Theme toggle
  1. Blocks
  2. Theme toggle
Blocks

Theme toggle

Controlled theme controls with a three-value switch, binary switch, cycle button, and dropdown.

Composition

How the block recipe nests its exported parts and installed agent primitives.

Controlled controls

Every exported control receives value and onValueChange from the host app.

Theme controls
├── ThemeSegmentedSwitch
│ ├── input type="radio"
│ └── icon / label
├── ThemeSwitch
│ └── Switch
├── ThemeToggle
│ └── Button
└── ThemeDropdown
├── MenuTrigger
└── MenuContent
└── MenuItem
Registry command
npx shadcn@latest add http://127.0.0.1:3000/r/refined/theme-toggle-block.json
See registry manifest

Usage

"use client";
​
import { type ThemeMode, ThemeSegmentedSwitch } from "@/components/refined-ui/blocks/theme-toggle";
​
type ThemeAdapter = {
theme: string | undefined;
setTheme: (value: string) => void;
};
​
function toThemeMode(value: string | undefined): ThemeMode {
if (value === "light" || value === "dark" || value === "system") return value;
return "system";
}
​
export function AppearanceControl({ theme, setTheme }: ThemeAdapter) {
return <ThemeSegmentedSwitch value={toThemeMode(theme)} onValueChange={(value) => setTheme(value)} />;
}
​

Agents used

The block command installs the recipe and these agent source files in one pass.

Block recipesrc/registry/blocks/refined/theme-toggle.tsx
Switch slotsrc/registry/sources/refined/ui/switch.tsx
Menu slotsrc/registry/sources/refined/ui/menu.tsx
Button slotsrc/registry/sources/refined/ui/button.tsx

On this page

  • Preview
  • Composition
  • Installation
  • Usage
  • Agents
AppearanceFollows device
Mode switch
System / light / dark
Dark mode
Light / dark
Cycle action
System