Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

ThemeState

interfaz Since 1.4.0

Lo que devuelve useTheme: la elección, el tema efectivo y la lista de temas.

ts
import type { ThemeState } from "@meekojs/meeko/framework";

Source code src/shared/theme.ts:150

Declaración #

ts
interface ThemeState<Name extends string = ThemeName, Choice extends string = ThemeChoice> {
	readonly theme: Signal<Choice>
	readonly resolved: ReadonlySignal<Name>
	readonly themes: readonly Name[]
	set(theme: Choice): void
}

Type parameters #

Name extends string = ThemeName

Nombres de los temas.

Choice extends string = ThemeChoice

Elecciones posibles: los temas y, si está activo, "system".

Example #

ts
import type { ThemeState } from "@meekojs/meeko/framework";

function next(state: ThemeState): void {
  state.set(state.resolved.value === "dark" ? "light" : "dark");
}

Miembros #

theme #

propiedad sólo lectura

readonly theme: Signal<Choice>

Elección actual, "system" incluido. Es editable (sirve para model="theme"): asignarla equivale a ThemeState.set. En el servidor es de sólo lectura.

resolved #

propiedad sólo lectura

readonly resolved: ReadonlySignal<Name>

Tema efectivo: la elección o, en "system", el tema de prefers-color-scheme. En SSR, si el servidor no conoce la preferencia (sin client hint), vale el tema claro de system.

themes #

propiedad sólo lectura

readonly themes: readonly Name[]

Temas de la configuración, sin "system".

set #

método

set(theme: Choice): void

Cambia la elección: actualiza <html>, color-scheme, la cookie y localStorage.

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/shared/theme.ts