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.

ThemeToggleState

interfaz Since 1.8.0

Lo que devuelve useThemeToggle: lo que necesita un selector de tema propio para pintar lo mismo en SSR y en la hidratación y para cambiar el tema sin JavaScript con el formulario de POST /_meeko/theme.

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

Source code src/shared/theme.ts:418

Declaración #

ts
interface ThemeToggleState<Name extends string = ThemeName, Choice extends string = ThemeChoice> {
	readonly theme: ThemeState<Name, Choice>
	readonly choices: readonly Choice[]
	readonly system: ThemeToggleSystem<Name> | undefined
	readonly known: ReadonlySignal<boolean>
	readonly interactive: ReadonlySignal<boolean>
}

Type parameters #

Name extends string = ThemeName
Choice extends string = ThemeChoice

Example #

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

const toggle = useThemeToggle();
const next = computed(() => {
  const index = toggle.choices.indexOf(toggle.theme.theme.value);
  return toggle.choices[(index + 1) % toggle.choices.length];
});

Propiedades #

theme #

propiedad sólo lectura

readonly theme: ThemeState<Name, Choice>

El estado del tema, el mismo que devuelve useTheme().

choices #

propiedad sólo lectura

readonly choices: readonly Choice[]

Las elecciones de la configuración en orden: los temas y, con el modo sistema, "system".

system #

propiedad sólo lectura

readonly system: ThemeToggleSystem<Name> | undefined

Los temas que muestra "system" según prefers-color-scheme; undefined sin modo sistema.

known #

propiedad sólo lectura

readonly known: ReadonlySignal<boolean>

Si este render conoce la elección del usuario: el servidor con la cookie, el navegador al terminar la hidratación. Mientras vale false, nombre la acción sin el tema actual.

interactive #

propiedad sólo lectura

readonly interactive: ReadonlySignal<boolean>

Si el selector ya responde en el navegador: false en SSR y durante la hidratación.

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