# Componente modalità notturna automatica

**URL:** https://meta.discourse.org/t/automatic-night-mode-component/115673
**Category:** Theme component
**Created:** [23 Aprile 2019, 3:53am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673 "2019-04-23T03:53:50Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![mbcahyono](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbcahyono/32/97721_2.png) [@mbcahyono](https://meta.discourse.org/u/mbcahyono)
#### Post date: [23 Aprile 2019, 3:53am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/1 "2019-04-23T03:53:50Z")

</div>

Following up the discussion here:

> [@Automatic Night Mode Plugin](https://meta.discourse.org/t/automatic-night-mode-plugin/86174):
>
> Some users have been asking about automatic switching between a light and a dark theme. Could this be accomplished with a plugin? I assume this would need two parts: a theme component with a javascript switching themes based on local time a Discourse plugin adding options to the user preferences page: turn night mode switching on/off, choose nighttime theme, set time nighttime time period How difficult would it be to code? As in, how much would it cost?

I made a theme component that will automatically switch to night theme based on user preferences. It’s currently work on a per-browser basis.

[Repository](https://github.com/muhlisbc/discourse-automatic-night-mode-theme)

```plaintext
https://github.com/muhlisbc/discourse-automatic-night-mode-theme

```

Screenshot:

 ![DeepinScreenshot_20190422123146](https://global.discourse-cdn.com/meta/original/3X/4/0/4024940d9faa75608377d8b11701ac9fde035eda.png)

### Installation

Add this component to each theme installed.

### Known Issues

- I’ve received a report of the component making all navigation cause full reloads. Upon navigating between different pages every click caused a full refresh instead of an in-app navigation. I have not been able to reproduce this, so please post reproduction steps if you run into this.

Feedback is welcome and thanks to Discourse team for sponsoring this work 🙂

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [8 Dicembre 2019, 8:26pm UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/3 "2019-12-08T20:26:51Z")

</div>

Bellissimo componente del tema. Ma non riesco a selezionare un intervallo di tempo per l’attivazione. Sembra che il campo sia valido solo per i fusi orari statunitensi?

È possibile aggiungere il rilevamento della modalità chiara/scura di macOS?

 ![Screenshot del 2019-12-08 alle 21.27.08](https://global.discourse-cdn.com/meta/original/3X/9/6/9691561bb7e14f55d10d1bd11d1de76d38c1fec2.png)

---

<div class="post-metadata">

### Author: ![mbcahyono](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbcahyono/32/97721_2.png) [@mbcahyono](https://meta.discourse.org/u/mbcahyono)
#### Post date: [9 Dicembre 2019, 12:41am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/4 "2019-12-09T00:41:17Z")

</div>

> [@terraboss](#):
>
> Sembra che il campo sia valido solo per i fusi orari statunitensi?

Sono certo che sia l’ora locale (del dispositivo).

> [@terraboss](#):
>
> È possibile aggiungere il rilevamento della modalità chiara/scura di macOS?

Esiste un altro tema per questo:

> [@Dark Mode Automatic Theme Switcher](https://meta.discourse.org/t/dark-mode-theme-switch-for-safari-on-macos-and-ios-13/112071):
>
> warning Discourse now supports [Automatic Dark Mode color scheme switching](https://meta.discourse.org/t/automatic-dark-mode-color-scheme-switching/161593) in core, this component is now deprecated and should no longer be used. [Repository](https://github.com/pmusaraj/discourse-dark-mode): https://github.com/pmusaraj/discourse-dark-mode Installation instructions: [Installing a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)What this does? This component allows automatic switching to a dark theme when the browser is set to dark mode. This works for logged-in users only on all browsers that support the [prefers-color-scheme](https://caniuse.com/#feat=prefers-color-scheme) media query. By de…

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [9 Dicembre 2019, 8:35am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/5 "2019-12-09T08:35:31Z")

</div>

> [@mbcahyono](#):
>
> Sono sicuro che sia l’ora locale (del dispositivo).

Non riesco a inserire manualmente la mia ora locale. Non succede nulla.

> [@mbcahyono](#):
>
> C’è un altro tema per quello:

Grazie per questo suggerimento! L’avevo già nei miei segnalibri 🙈

Purtroppo, al momento non funziona. Devo prima fare un po’ di risoluzione dei problemi…

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [17 Febbraio 2020, 10:27am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/6 "2020-02-17T10:27:29Z")

</div>

È possibile combinare questo componente del tema con questo?

> [@Theme Switcher Component](https://meta.discourse.org/t/theme-switcher-component/113460/18):
>
> Any thoughts about making the bottom smaller? When using additional component, it takes a lot of space in the header. For example I like the dark mode button in this ghost theme at top right:

In questo modo, gli utenti potrebbero sovrascrivere la modalità scura automatica, quando desiderato.

---

<div class="post-metadata">

### Author: ![mbcahyono](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbcahyono/32/97721_2.png) [@mbcahyono](https://meta.discourse.org/u/mbcahyono)
#### Post date: [17 Febbraio 2020, 11:52am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/7 "2020-02-17T11:52:24Z")

</div>

Sì, puoi farlo, ma potrebbe causare comportamenti inaspettati.

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [4 Agosto 2020, 12:28pm UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/8 "2020-08-04T12:28:07Z")

</div>

Sembra che questo componente sia rotto. Ogni volta che lo abilito nelle impostazioni del mio profilo e ricarico la pagina, la spunta nella casella scompare e viene disabilitato.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5 Agosto 2020, 12:15am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/9 "2020-08-05T00:15:20Z")

</div>

Credo che @pmusaraj stia lavorando a qualcosa di ancora più automatico di questo.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [25 Agosto 2020, 1:48pm UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/10 "2020-08-25T13:48:03Z")

</div>

Core ora ha una funzionalità simile basata sull’interfaccia utente in modalità scura del dispositivo; consulta [Cambio automatico dello schema colori in modalità scura](https://meta.discourse.org/t/automatic-dark-mode-color-scheme-switching/161593).

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [5 Dicembre 2020, 3:36am UTC](https://meta.discourse.org/t/automatic-night-mode-component/115673/11 "2020-12-05T03:36:25Z")

</div>


