Primitives

ThemeToggle

A control for switching between light and dark themes.

Basic Toggle

basic
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<ThemeToggle />

Sizes

sizes
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<div class="flex flex-wrap items-center gap-4">
  <ThemeToggle size="xs" />
  <ThemeToggle size="sm" />
  <ThemeToggle size="md" />
  <ThemeToggle size="lg" />
  <ThemeToggle size="xl" />
</div>

Variants

variants
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<div class="flex flex-wrap gap-4">
  <ThemeToggle variant="solid" />
  <ThemeToggle variant="outline" />
  <ThemeToggle variant="ghost" />
</div>

Intent Colors

intents
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<div class="flex flex-wrap gap-4">
  <ThemeToggle intent="primary" variant="solid" />
  <ThemeToggle intent="secondary" variant="solid" />
  <ThemeToggle intent="accent" variant="solid" />
  <ThemeToggle intent="neutral" variant="outline" />
</div>

Shapes

shapes
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<div class="flex flex-wrap gap-4">
  <ThemeToggle shape="rounded" />
  <ThemeToggle shape="square" />
  <ThemeToggle shape="pill" />
</div>

Custom Configuration

custom-icons
---
import ThemeToggle from '@alfadormx/blocks/primitives/ThemeToggle.astro';
---

<div class="flex flex-wrap gap-4">
  <ThemeToggle icon={{ name: 'heroicons:moon' }} variant="solid" intent="primary" size="lg" />
  <ThemeToggle
    icon={{ name: 'heroicons:light-bulb' }}
    variant="outline"
    intent="accent"
    size="lg"
    shape="pill"
  />
</div>

Theme Demo Content

This is normal text that adapts to the theme. Toggle the theme to see it change!

This is muted text with lower contrast.

This is emphasized text with higher contrast.

Content on a surface background

Content on an elevated background

API Reference

ThemeToggle accepts all Button props — see its API Reference for the full list.