Daylight Switch
Install the component, then paste your configured usage. Your settings are included in the code below.
Pro source comes with Arclen UI Pro. See plans
| Property | Type | Default |
|---|---|---|
accessibleNameAccessible name Nonblank accessible name of the switch; unrelated to host theme ownership. Up to 120 characters | text | "Night mode" |
checkedOn | boolean | false |
disabledDisabled | boolean | false |
widthWidth Requested width in CSS pixels; fit a narrower container while retaining 2:1 geometry. 120–520Step 2 | number | 260 |
trackTopTrack top | color | "#e8eaf0" |
trackBottomTrack bottom | color | "#d9dce5" |
trackEdgeTrack edge | color | "#c9cdd7" |
inkColorLiquid | color | "#111111" |
thumbColorThumb / solar ivory | color | "#f8f8f6" |
shadowStrengthShadow strength 0–1.5Step 0.1 | number | 1 |
motionDurationMaterial timing Material transition duration in milliseconds. 440–1400Step 20 | number | 880 |
elasticityOrb elasticity 0–0.075Step 0.005 | number | 0.045 |
surfaceLagLunar reveal lag Delay before the lunar surface begins to appear, as a fraction of the material transition duration. 0–0.2Step 0.01 | number | 0.09 |
sunGlowSolar glow 0–0.5Step 0.02 | number | 0.28 |
moonImageLunar texture Bundled original generated lunar image; empty or failed image uses an opaque shaded fallback. Up to 4096 characters | image | "assets/moon-realistic.png" |
moonCropScaleLunar crop scale 1–1.2Step 0.01 | number | 1.08 |
moonContrastLunar contrast 0.8–1.2Step 0.05 | number | 1 |
limbShadingLimb shading 0–0.35Step 0.01 | number | 0.17 |
Daylight Switch
A liquid switch with an ivory day surface and an original lunar texture. It changes its own checked state. Your application decides what that state means.
React
import { useState } from 'react';
import { DaylightSwitch } from './components/daylight-switch';
export function Example() {
const [checked, setChecked] = useState(false);
return (
<DaylightSwitch
checked={checked}
onCheckedChange={setChecked}
accessibleName="Reading mode"
/>
);
}For local state, omit checked and use defaultChecked if needed. When both are absent, the component uses its configured manifest default. Do not supply both props or change between controlled and uncontrolled mode while mounted. className, style and paused apply to the wrapper; the ordinary settings are individual props. Component is an alias of DaylightSwitch.
HTML and vanilla JavaScript
The HTML download includes the script, CSS, artwork and static poster. Keep those files together when moving the download beneath a subpath.
import { defaults, mount } from './components/daylight-switch/src/core';
import './components/daylight-switch/src/styles.css';
const switchElement = document.querySelector<HTMLElement>('#reading-switch')!;
const controller = mount(switchElement, { ...defaults }, undefined, {
onCheckedChange(checked, detail) {
console.log(checked, detail.source);
},
});
controller.update({ ...defaults, checked: true, width: 180 });
controller.pause();
controller.resume();
// When the host is removed:
controller.destroy();update receives a complete settings vector and assigns its checked state without emitting a user event. Preserve the current checked value when changing only appearance. Invalid settings throw before changing the instance. You can also listen for the bubbling daylight-change event on the host. Use either the callback or event for a given action; both report the same user request once.
Vanilla mounts manage local state unless the optional fourth argument sets controlled: true. A controlled mount reports user requests and waits for update to supply the new checked value. Every instance is independent. The component never changes page classes, reads color-scheme preferences, writes storage or starts a page transition.
Settings and presets
The inspector and generated settings table use component.json as the source of defaults. Ivory daylight is the default. Lunar night starts checked; Quiet daylight reduces elasticity and glow; Expressive lunar adds more recoil and material contrast. All presets are complete, portable settings vectors.
Width sets the drawing width; height remains half the available width. A narrow receiving container scales the drawing proportionally. Material timing scales the liquid, travel and surface change together. Lunar reveal lag controls when the feathered surface begins to appear. Orb elasticity affects the whole orb, including its texture and mask. Lunar crop and contrast apply only to the lunar image. Thumb color remains the solar base and the shaded lunar fallback. Shadow strength zero removes the contact shadows.
The bundled lunar artwork loads locally. A custom image must use a supported image URL or raster data URL. Empty or failed images show an opaque shaded sphere, and stale loads cannot replace a newer selection. Only a configured custom URL creates an external image request.
Accessibility and lifecycle
The native button has switch semantics and a nonblank accessible name. Space and Enter toggle once; left/down arrows set off and right/up arrows set on. Disabled switches reject user actions but accept external checked updates. Keyboard focus remains visible, and the stationary target does not shrink with the orb.
Reduced motion removes decorative travel, deformation and reveal, including when the preference changes during a transition. Explicit pause, offscreen visibility and a hidden document settle at the logical endpoint and stop frame work. Resume permits future motion without replaying a stale transition. There is no idle animation loop. Missing motion-preference APIs use the static fallback; missing intersection observation retains manual pause and document visibility handling.
Server rendering reflects the supplied settings with an inert button. The HTML download without JavaScript retains its default static markup and poster; exported configuration applies when the script mounts. Mount activates the existing control. destroy removes listeners and observers, cancels frame work and invalidates asset callbacks; it leaves an inert static endpoint. Calling it twice is safe.
Artwork
The lunar disk is original generated artwork, not a scientific photograph. Its notice ships in assets/NOTICE.md. The component includes no font, remote script or animation dependency.
The preview runs the component’s own JavaScript. It respects reduced motion and pauses when off screen. The HTML bundle includes a static fallback.
Every setting in this panel comes from the component manifest. Preview size, pause and replay stay in the inspector.