DaisyThemeController

Overview

DaisyThemeController

DaisyThemeController is a toggle-based switch for applying Daisy themes via DaisyThemeManager. It supports multiple display modes (toggle, checkbox, swap, text/icon variants) and syncs IsChecked with the current theme. Switching updates CheckedTheme/UncheckedTheme and can auto-adopt new themes.

How Theming Works

This control uses DaisyThemeManager internally, which works with Avalonia's ThemeDictionaries architecture:

Properties

Property Description
Mode Visual mode: Toggle, Checkbox, Swap, ToggleWithText, ToggleWithIcons.
UncheckedLabel / CheckedLabel Labels for light/dark (or custom) modes.
UncheckedTheme / CheckedTheme Theme names to apply on off/on states (defaults: Light/Dark).

Behavior

Quick Examples

In your .axaml file (e.g., MainWindow.axaml), add the namespace and control:

<!-- Add at top of file -->
xmlns:controls="clr-namespace:Flowery.Controls;assembly=Flowery.NET"

<!-- Simple toggle - just drop it in, defaults to Light/Dark -->
<controls:DaisyThemeController Mode="Toggle" />

<!-- Animated sun/moon swap (as used in Gallery) -->
<controls:DaisyThemeController Mode="Swap" />

<!-- Custom theme pairing -->
<controls:DaisyThemeController Mode="ToggleWithText"
    UncheckedTheme="Light" CheckedTheme="Synthwave"
    UncheckedLabel="Light" CheckedLabel="Synthwave" />
Prerequisite: Your App.axaml must include in Application.Styles. If you're not using another base theme (like Semi or Material), add as the minimum required for core Avalonia controls to render properly.

Tips & Best Practices