### Switch Component Implementations in ClojureScript Source: https://context7.com/sudorock/headlessui-reagent/llms.txt Provides examples of Switch components for boolean settings using Headless UI and Reagent. It covers a controlled switch with a label and description, demonstrating state management via an atom and conditional styling. An example of a simple, uncontrolled switch is also included. ```clojure (require '[headlessui-reagent.core :as ui]) (require '[reagent.core :as r]) ;; Switch with label and description (r/with-let [!enabled (r/atom false)] [ui/switch-group {:as :div, :class [:flex :items-center :space-x-4]} [ui/switch-label {:class [:text-sm :font-medium :text-gray-700]} "Enable notifications"] [ui/switch {:checked @!enabled :on-change #(reset! !enabled %) :class (fn [{:keys [checked]}] [:relative :inline-flex :h-6 :w-11 :items-center :rounded-full :transition-colors :focus:outline-none :focus:ring-2 :focus:ring-offset-2 :focus:ring-blue-500 (if checked :bg-blue-600 :bg-gray-200)])} [:span {:class (fn [{:keys [checked]}] [:inline-block :h-4 :w-4 :transform :rounded-full :bg-white :transition-transform (if checked :translate-x-6 :translate-x-1)])}]] [ui/switch-description {:class [:text-sm :text-gray-500]} "Receive email notifications for updates"]]) ;; Simple uncontrolled switch [ui/switch {:class (fn [{:keys [checked]}] [:relative :inline-flex :h-6 :w-11 :rounded-full (if checked :bg-green-500 :bg-gray-300)])} [:span.sr-only "Toggle setting"]] ``` -------------------------------- ### Menu Component Examples in ClojureScript Source: https://context7.com/sudorock/headlessui-reagent/llms.txt Illustrates the implementation of the Menu component in headlessui-reagent, showcasing a complete dropdown with keyboard navigation and focus management. It details how to structure menu items and apply conditional styling based on active states. ```clojurescript (require '[headlessui-reagent.core :as ui]) ;; Complete dropdown menu with keyboard navigation [ui/menu {:as :div, :class [:relative :inline-block :text-left]} [ui/menu-button {:class [:inline-flex :justify-center :w-full :rounded-md :border :border-gray-300 :shadow-sm :px-4 :py-2 :bg-white :text-sm :font-medium :text-gray-700 :hover:bg-gray-50]} "Options"] [ui/menu-items {:class [:absolute :right-0 :w-56 :mt-2 :origin-top-right :bg-white :divide-y :divide-gray-100 :rounded-md :shadow-lg :ring-1 :ring-black :ring-opacity-5 :focus:outline-none]} [ui/menu-item (fn [{:keys [active]}] [:a.block {:href "#/edit" :class [:px-4 :py-2 :text-sm (if active :bg-blue-500 :text-gray-900) (when active :text-white)]} "Edit"])] [ui/menu-item (fn [{:keys [active]}] [:button.w-full.text-left {:class [:px-4 :py-2 :text-sm (if active :bg-blue-500 :text-gray-900) (when active :text-white)]} "Delete"])]] ``` -------------------------------- ### Rendering Custom Elements with :as Prop in Reagent Source: https://github.com/sudorock/headlessui-reagent/blob/main/README.md Demonstrates rendering a headlessui-reagent component as a different HTML element using the :as prop. This example shows how to render a disclosure panel as a `