"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[2974],{3905:function(e,t,r){r.d(t,{Zo:function(){return d},kt:function(){return m}});var n=r(7294);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var s=n.createContext({}),c=function(e){var t=n.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},d=function(e){var t=c(e.components);return n.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,d=l(e,["components","mdxType","originalType","parentName"]),f=c(r),m=o,u=f["".concat(s,".").concat(m)]||f[m]||p[m]||a;return r?n.createElement(u,i(i({ref:t},d),{},{components:r})):n.createElement(u,i({ref:t},d))}));function m(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=r.length,i=new Array(a);i[0]=f;var l={};for(var s in t)hasOwnProperty.call(t,s)&&(l[s]=t[s]);l.originalType=e,l.mdxType="string"==typeof e?e:o,i[1]=l;for(var c=2;c<a;c++)i[c]=r[c];return n.createElement.apply(null,i)}return n.createElement.apply(null,r)}f.displayName="MDXCreateElement"},4897:function(e,t,r){r.r(t),r.d(t,{frontMatter:function(){return l},contentTitle:function(){return s},metadata:function(){return c},toc:function(){return d},default:function(){return f}});var n=r(7462),o=r(3366),a=(r(7294),r(3905)),i=["components"],l={title:"Dark mode",sidebar_position:8.5},s=void 0,c={unversionedId:"overview/darkmode",id:"overview/darkmode",isDocsHomePage:!1,title:"Dark mode",description:"If you use Sass to develop, there is a predefined placeholder selector for dark mode, this file is in /scss/helpers/_dark-mode.scss, in this file the %dark-mode selector is defined you can create your selectors by extending it.",source:"@site/docs/overview/darkmode.mdx",sourceDirName:"overview",slug:"/overview/darkmode",permalink:"/docs/overview/darkmode",editUrl:"https://github.com/amir2mi/flatifycss/tree/master/website/docs/overview/darkmode.mdx",tags:[],version:"current",sidebarPosition:8.5,frontMatter:{title:"Dark mode",sidebar_position:8.5},sidebar:"tutorialSidebar",previous:{title:"Right to left",permalink:"/docs/overview/rtl"},next:{title:"Customization",permalink:"/docs/overview/customization"}},d=[],p={toc:d};function f(e){var t=e.components,r=(0,o.Z)(e,i);return(0,a.kt)("wrapper",(0,n.Z)({},p,r,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("p",null,"If you use Sass to develop, there is a predefined placeholder selector for dark mode, this file is in ",(0,a.kt)("inlineCode",{parentName:"p"},"/scss/helpers/_dark-mode.scss"),", in this file the ",(0,a.kt)("inlineCode",{parentName:"p"},"%dark-mode")," selector is defined you can create your selectors by extending it.",(0,a.kt)("br",{parentName:"p"}),"\n","Here is an example of a dark mode selector:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-scss",metastring:'title="style.scss"',title:'"style.scss"'},"html.dark {\n  @extend %dark-mode;\n}\n")),(0,a.kt)("p",null,"or you can detect automatically if users prefer dark theme with ",(0,a.kt)("a",{parentName:"p",href:"https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme"},"CSS ",(0,a.kt)("inlineCode",{parentName:"a"},"@media")," feature"),":"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-scss",metastring:'title="style.scss"',title:'"style.scss"'},"@media (prefers-color-scheme: dark) {\n  :root {\n    @extend %dark-mode;\n  }\n}\n")),(0,a.kt)("p",null,"Now if the ",(0,a.kt)("inlineCode",{parentName:"p"},"<html>")," tag has the ",(0,a.kt)("inlineCode",{parentName:"p"},".dark")," class or the user prefers to have a dark theme, the dark mode will be applied.",(0,a.kt)("br",{parentName:"p"}),"\n","Note that you should extend this selector as ",(0,a.kt)("inlineCode",{parentName:"p"},"<html>")," tag because it changes CSS variables that are defined as the ",(0,a.kt)("inlineCode",{parentName:"p"},":root"),"."),(0,a.kt)("p",null,"Simply by extending, it will change some CSS variables for dark mode state. Like this:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-css",metastring:'title="style.scss"',title:'"style.scss"'},"@media (prefers-color-scheme: dark) {\n  :root {\n    // Increase brightness\n    --flatify__hover-brightness: 110%;\n\n    // Background color\n    --flatify__bg-color: #10191c !important;\n    --flatify__bg-color-dark: #141f23 !important;\n    --flatify__bg-color-darker: #263b43 !important;\n    --flatify__bg-color-darkest: #385661 !important;\n    --flatify__color-light-light: #141f23 !important;\n    --flatify__color-light-primary: #10191c !important;\n    --flatify__color-light-dark: #263b43 !important;\n\n    // Text color\n    --flatify__txt-color: #f1f4f7;\n    --flatify__txt-color-dark: #ced9e3;\n    --flatify__txt-color-darker: #809cb6;\n    --flatify__txt-color-inverted: #141f23;\n    --flatify__color-dark-light: #f1f4f7;\n    --flatify__color-dark-primary: #ced9e3;\n    --flatify__color-dark-dark: #809cb6;\n  }\n}\n")))}f.isMDXComponent=!0}}]);