{"id":"6b09417e5ce40d447918f2c1","slug":"mui","title":"MUI 7 w praktyce – motyw, tryb ciemny, własne komponenty i DataGrid bez „domyślnego Materiala”","summary":"Budujemy panel kuchni pierogarni w Material UI 7 – tokeny projektowe i motyw ze zmiennymi CSS, tryb ciemny bez migotania, własne komponenty i warianty, DataGrid po stronie klienta i serwera, formularz z react-hook-form i Zod. Kod działa też na MUI 9.","servedLang":"pl","availableLangs":["pl","en"],"topics":["mui","react"],"techs":["typescript","javascript"],"tags":["material-ui","mui-7","mui-x","data-grid","design-tokens","dark-mode","theming","react-hook-form","zod"],"level":"intermediate","kind":"tutorial","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":22,"stats":{"views":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T08:38:22.505Z","updatedAt":"2026-11-27T10:03:40.930Z","requestedLang":"pl","theme":{"hero":"classic","heroMedia":null,"accent":"indigo","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"Material UI (MUI 7) krok po kroku – createTheme z colorSchemes i cssVariables, design tokens, dark mode z useColorScheme, styled i sx, własny wariant przycisku, augmentacja typów, MUI X DataGrid (paginacja serwerowa, akcje), formularze z react-hook-form + Zod i jak uniknąć domyślnego wyglądu Materia","wordCount":4330,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"MUI to najpopularniejsza biblioteka komponentów dla Reacta, ale ma jedną wadę wizerunkową: aplikacje zbudowane „na domyślnych ustawieniach” wyglądają identycznie – niebieski pasek, wielkie litery na przyciskach, cienie pod każdą kartą. W tym poradniku zbudujesz panel kuchni pierogarni, który korzysta z całej mocy MUI (dostępność, gotowe komponenty, DataGrid), ale wygląda jak produkt z własnym systemem projektowym."}]},{"type":"callout","attrs":{"variant":"info","title":"W skrócie"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Najpierw tokeny, potem motyw.","marks":[{"type":"bold"}]},{"type":"text","text":" Kolory, promienie i fonty żyją w jednym pliku "},{"type":"text","text":"tokens.ts","marks":[{"type":"code"}]},{"type":"text","text":", a "},{"type":"text","text":"createTheme","marks":[{"type":"code"}]},{"type":"text","text":" tylko je mapuje. Zmiana marki to zmiana jednego pliku, nie stu komponentów."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Zmienne CSS + ","marks":[{"type":"bold"}]},{"type":"text","text":"colorSchemes","marks":[{"type":"code"}]},{"type":"text","text":" dają tryb jasny, ciemny i systemowy bez ponownego renderowania Reacta i bez migotania przy starcie. Hook "},{"type":"text","text":"useColorScheme()","marks":[{"type":"code"}]},{"type":"text","text":" przełącza tryb i zapamiętuje wybór."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"DataGrid","marks":[{"type":"bold"}]},{"type":"text","text":" z MUI X obsługuje sortowanie, filtry, paginację i akcje w wierszu. Przy dużych zbiorach przełączasz go w tryb serwerowy, a dane dostarcza TanStack Query."}]}]}]}]},{"type":"callout","attrs":{"variant":"tip","title":"Co zbudujesz"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Panel administracyjny „Pierogarnia · Kitchen” w Vite + React 19 + MUI 7: kafelki statystyk, tabelę 240 zamówień (sortowanie, filtrowanie, zaznaczanie, anulowanie z menu wiersza), drugą tabelę w trybie serwerowym, formularz dodawania dania z walidacją Zod oraz przełącznik trybu jasny / systemowy / ciemny. Kod (16 plików) sprawdziliśmy na MUI 7.3 i MUI 9.6 – pobierzesz go jako ZIP ikoną przy artykule."}]}]},{"type":"paragraph","content":[{"type":"text","text":"Wymagania wstępne:","marks":[{"type":"bold"}]},{"type":"text","text":" React z hookami i TypeScript na poziomie "},{"type":"text","text":"poradnika TypeScript","marks":[{"type":"link","attrs":{"href":"/pl/articles/typescript"}}]},{"type":"text","text":". Przyda się znajomość react-hook-form i TanStack Query z "},{"type":"text","text":"poradnika React","marks":[{"type":"link","attrs":{"href":"/pl/articles/react"}}]},{"type":"text","text":", ale nie jest konieczna."}]},{"type":"stats","attrs":{"items":[{"value":"7 → 9","label":"wersje MUI","hint":"ten sam kod działa na obu"},{"value":"3","label":"tryby kolorów","hint":"jasny, ciemny, systemowy"},{"value":"240","label":"wierszy w DataGrid","hint":"sortowanie, filtry i akcje bez własnego kodu"},{"value":"1","label":"plik z tokenami","hint":"cała marka w jednym miejscu"}]}},{"type":"heading","attrs":{"level":2,"id":"krok-1-instalacja"},"content":[{"type":"text","text":"Krok 1. Instalacja"}]},{"type":"codeBlock","attrs":{"language":"bash"},"content":[{"type":"text","text":"npm create vite@latest pierogi-admin -- --template react-ts\ncd pierogi-admin\nnpm install @mui/material @mui/icons-material @emotion/react @emotion/styled @mui/x-data-grid @fontsource-variable/inter\nnpm install react-hook-form @hookform/resolvers zod @tanstack/react-query"}]},{"type":"paragraph","content":[{"type":"text","text":"MUI używa Emotion jako silnika stylów, stąd dwa pakiety "},{"type":"text","text":"@emotion/*","marks":[{"type":"code"}]},{"type":"text","text":". Font Inter instalujesz lokalnie przez Fontsource – bez zapytań do Google Fonts i bez skoku układu po doczytaniu fontu z sieci."}]},{"type":"codeGroup","attrs":{"title":"Konfiguracja projektu"},"content":[{"type":"codeBlock","attrs":{"language":"json","filename":"package.json"},"content":[{"type":"text","text":"{\n  \"name\": \"pierogi-admin-mui\",\n  \"private\": true,\n  \"version\": \"0.1.0\",\n  \"type\": \"module\",\n  \"scripts\": {\n    \"dev\": \"vite\",\n    \"build\": \"tsc --noEmit && vite build\",\n    \"preview\": \"vite preview\"\n  },\n  \"dependencies\": {\n    \"@emotion/react\": \"^11.14.0\",\n    \"@emotion/styled\": \"^11.14.1\",\n    \"@fontsource-variable/inter\": \"^5.3.0\",\n    \"@hookform/resolvers\": \"^7.0.9\",\n    \"@mui/icons-material\": \"^7.3.11\",\n    \"@mui/material\": \"^7.3.11\",\n    \"@mui/x-data-grid\": \"^9.18.0\",\n    \"@tanstack/react-query\": \"^5.108.4\",\n    \"react\": \"^19.3.1\",\n    \"react-dom\": \"^19.3.1\",\n    \"react-hook-form\": \"^7.92.0\",\n    \"zod\": \"^4.6.7\"\n  },\n  \"devDependencies\": {\n    \"@types/react\": \"^19.3.0\",\n    \"@types/react-dom\": \"^19.3.0\",\n    \"@vitejs/plugin-react\": \"^6.3.0\",\n    \"typescript\": \"~7.0.2\",\n    \"vite\": \"^8.4.0\"\n  }\n}"}]},{"type":"codeBlock","attrs":{"language":"json","filename":"tsconfig.json"},"content":[{"type":"text","text":"{\n  \"compilerOptions\": {\n    \"target\": \"es2023\",\n    \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"bundler\",\n    \"types\": [\"vite/client\"],\n    \"jsx\": \"react-jsx\",\n    \"noEmit\": true,\n    \"allowImportingTsExtensions\": true,\n    \"verbatimModuleSyntax\": true,\n    \"skipLibCheck\": true,\n    \"noUncheckedIndexedAccess\": true\n  },\n  \"include\": [\"src\", \"vite.config.ts\"]\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"vite.config.ts"},"content":[{"type":"text","text":"import react from \"@vitejs/plugin-react\";\nimport { defineConfig } from \"vite\";\n\nexport default defineConfig({\n  plugins: [react()],\n});"}]},{"type":"codeBlock","attrs":{"language":"html","filename":"index.html"},"content":[{"type":"text","text":"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>Pierogarnia · Kitchen admin</title>\n  </head>\n  <body>\n    <div id=\"root\"></div>\n    <script type=\"module\" src=\"/src/main.tsx\"></script>\n  </body>\n</html>"}]}]},{"type":"heading","attrs":{"level":2,"id":"krok-2-tokeny-projektowe-i-motyw"},"content":[{"type":"text","text":"Krok 2. Tokeny projektowe i motyw"}]},{"type":"paragraph","content":[{"type":"text","text":"Tokeny projektowe (design tokens)","marks":[{"type":"bold"}]},{"type":"text","text":" to nazwane decyzje: „kolor marki 700”, „promień średni”, „font bezszeryfowy”. Motyw MUI jest tylko jednym z ich odbiorców – te same tokeny możesz wyeksportować do e-maili, wykresów czy aplikacji mobilnej."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  T[\"tokens.ts<br/>brand, neutral, status, radius, font\"] --> C[\"createTheme()<br/>colorSchemes light/dark<br/>typography, shape, components\"]\n  C --> V[\"Zmienne CSS<br/>--mui-palette-primary-main…\"]\n  V --> K[\"Komponenty MUI<br/>Button, Card, DataGrid\"]\n  V --> W[\"Własne komponenty<br/>styled(), sx\"]\n  A[\"mui.d.ts<br/>augmentacja typów\"] -.-> C\n  A -.-> W","caption":"Od tokenów do komponentów: jedno źródło decyzji, zero kolorów wpisanych w komponenty"}},{"type":"paragraph","content":[{"type":"text","text":"Trzy pliki motywu: tokeny, deklaracje typów (augmentacja modułu) i sam motyw:"}]},{"type":"codeGroup","attrs":{"title":"Tokeny, typy i motyw"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/theme/tokens.ts"},"content":[{"type":"text","text":"// Design tokens: the single source of brand decisions. The MUI theme only maps them.\nexport const tokens = {\n  font: {\n    sans: '\"Inter Variable\", system-ui, -apple-system, \"Segoe UI\", sans-serif',\n  },\n  radius: { sm: 6, md: 10, lg: 14 },\n  // \"Beetroot\" brand scale instead of the default Material blue.\n  brand: { 50: \"#fff0f6\", 100: \"#ffdeeb\", 300: \"#faa2c1\", 500: \"#e64980\", 700: \"#c2255c\", 900: \"#a61e4d\" },\n  neutral: {\n    0: \"#ffffff\", 50: \"#f8f9fa\", 100: \"#f1f3f5\", 200: \"#e9ecef\", 300: \"#dee2e6\",\n    500: \"#868e96\", 700: \"#495057\", 800: \"#2b2f36\", 900: \"#1d2026\", 950: \"#141619\",\n  },\n  status: {\n    light: { placed: \"#1971c2\", cooking: \"#d9480f\", delivering: \"#6741d9\", delivered: \"#2b8a3e\", cancelled: \"#868e96\" },\n    dark: { placed: \"#74c0fc\", cooking: \"#ffa94d\", delivering: \"#b197fc\", delivered: \"#8ce99a\", cancelled: \"#adb5bd\" },\n  },\n} as const;\n\nexport type OrderStatus = keyof typeof tokens.status.light;"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/theme/mui.d.ts"},"content":[{"type":"text","text":"import type { OrderStatus } from \"./tokens.ts\";\n\n// Module augmentation: teach MUI's types about our custom theme parts.\ndeclare module \"@mui/material/styles\" {\n  // We always enable CSS variables, so `theme.vars` is never undefined.\n  interface CssThemeVariables {\n    enabled: true;\n  }\n  interface Palette {\n    status: Record<OrderStatus, string>;\n  }\n  interface PaletteOptions {\n    status?: Record<OrderStatus, string>;\n  }\n}\n\ndeclare module \"@mui/material/Button\" {\n  interface ButtonPropsVariantOverrides {\n    soft: true;\n  }\n}"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/theme/theme.ts"},"content":[{"type":"text","text":"import { createTheme } from \"@mui/material/styles\";\nimport { tokens } from \"./tokens.ts\";\n\nconst { brand, neutral, radius, status } = tokens;\n\nexport const theme = createTheme({\n  // CSS variables + a class on <html> switch light/dark without re-rendering React.\n  cssVariables: { colorSchemeSelector: \"class\" },\n  colorSchemes: {\n    light: {\n      palette: {\n        primary: { main: brand[700], light: brand[500], dark: brand[900], contrastText: \"#fff\" },\n        background: { default: neutral[50], paper: neutral[0] },\n        text: { primary: neutral[900], secondary: neutral[700] },\n        divider: neutral[200],\n        status: status.light,\n      },\n    },\n    dark: {\n      palette: {\n        primary: { main: brand[300], light: brand[100], dark: brand[500], contrastText: neutral[950] },\n        background: { default: neutral[950], paper: neutral[900] },\n        text: { primary: neutral[100], secondary: neutral[500] },\n        divider: \"rgba(255, 255, 255, 0.10)\",\n        status: status.dark,\n      },\n    },\n  },\n  shape: { borderRadius: radius.md },\n  typography: {\n    fontFamily: tokens.font.sans,\n    h1: { fontSize: \"1.75rem\", fontWeight: 700, letterSpacing: \"-0.02em\" },\n    h2: { fontSize: \"1.25rem\", fontWeight: 650, letterSpacing: \"-0.01em\" },\n    overline: { fontWeight: 600, letterSpacing: \"0.06em\" },\n    button: { textTransform: \"none\", fontWeight: 600 }, // no SHOUTING buttons\n  },\n  components: {\n    MuiButtonBase: { defaultProps: { disableRipple: true } },\n    MuiButton: {\n      defaultProps: { disableElevation: true },\n      styleOverrides: {\n        root: ({ theme }) => ({\n          borderRadius: radius.sm,\n          \"&.Mui-focusVisible\": { outline: `2px solid ${theme.vars.palette.primary.main}`, outlineOffset: 2 },\n          // Custom variant registered in mui.d.ts: <Button variant=\"soft\">\n          variants: [\n            {\n              props: { variant: \"soft\" },\n              style: {\n                color: theme.vars.palette.primary.main,\n                backgroundColor: theme.alpha(theme.vars.palette.primary.main, 0.12),\n                \"&:hover\": { backgroundColor: theme.alpha(theme.vars.palette.primary.main, 0.2) },\n              },\n            },\n          ],\n        }),\n      },\n    },\n    MuiPaper: { defaultProps: { elevation: 0 }, styleOverrides: { root: { backgroundImage: \"none\" } } },\n    MuiCard: { defaultProps: { variant: \"outlined\" } },\n    MuiAppBar: {\n      defaultProps: { elevation: 0, color: \"inherit\", position: \"sticky\" },\n      styleOverrides: { root: ({ theme }) => ({ borderBottom: `1px solid ${theme.vars.palette.divider}` }) },\n    },\n    MuiTextField: { defaultProps: { size: \"small\", fullWidth: true } },\n    MuiChip: { styleOverrides: { root: { fontWeight: 600, borderRadius: radius.sm } } },\n    MuiTooltip: { defaultProps: { arrow: true } },\n  },\n});"}]}]},{"type":"paragraph","content":[{"type":"text","text":"Co tu się dzieje:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"cssVariables: { colorSchemeSelector: \"class\" }","marks":[{"type":"code"}]},{"type":"text","text":" – MUI generuje zmienne CSS ("},{"type":"text","text":"--mui-palette-primary-main","marks":[{"type":"code"}]},{"type":"text","text":") i przełącza schemat klasą "},{"type":"text","text":".dark","marks":[{"type":"code"}]},{"type":"text","text":" na "},{"type":"text","text":"<html>","marks":[{"type":"code"}]},{"type":"text","text":". Komponenty odwołują się do zmiennych, więc zmiana trybu to tylko zmiana klasy, bez ponownego renderowania drzewa Reacta."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"colorSchemes.light","marks":[{"type":"code"}]},{"type":"text","text":" / ","marks":[{"type":"bold"}]},{"type":"text","text":"colorSchemes.dark","marks":[{"type":"code"}]},{"type":"text","text":" – dwa zestawy palet z tych samych tokenów. W trybie ciemnym kolor główny jest jaśniejszy ("},{"type":"text","text":"brand[300]","marks":[{"type":"code"}]},{"type":"text","text":"), żeby zachować kontrast."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"theme.vars.palette…","marks":[{"type":"code"}]},{"type":"text","text":" w nadpisaniach zamiast "},{"type":"text","text":"theme.palette…","marks":[{"type":"code"}]},{"type":"text","text":" – wartość zmiennej CSS, a nie stały kolor jasnego motywu. Dzięki augmentacji "},{"type":"text","text":"CssThemeVariables { enabled: true }","marks":[{"type":"code"}]},{"type":"text","text":" TypeScript wie, że "},{"type":"text","text":"theme.vars","marks":[{"type":"code"}]},{"type":"text","text":" zawsze istnieje."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"components","marks":[{"type":"code"}]},{"type":"text","text":" – domyślne propsy i nadpisania stylów dla wszystkich instancji komponentu. To tu znikają cienie, ripple i wielkie litery."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Własny wariant ","marks":[{"type":"bold"}]},{"type":"text","text":"soft","marks":[{"type":"code"}]},{"type":"text","text":" – rejestrujesz go w "},{"type":"text","text":"ButtonPropsVariantOverrides","marks":[{"type":"code"}]},{"type":"text","text":", a styl dodajesz w "},{"type":"text","text":"styleOverrides.root.variants","marks":[{"type":"code"}]},{"type":"text","text":". Od tej chwili "},{"type":"text","text":"<Button variant=\"soft\">","marks":[{"type":"code"}]},{"type":"text","text":" jest typowany i podpowiadany w edytorze."}]}]}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Domyślny MUI"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"W tym projekcie"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Gdzie"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"niebieski "},{"type":"text","text":"#1976d2","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"„buraczkowa” skala marki z tokenów"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"colorSchemes.*.palette.primary","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Roboto"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Inter Variable z Fontsource"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"typography.fontFamily","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"BUTTON","marks":[{"type":"code"}]},{"type":"text","text":" wielkimi literami"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"textTransform: \"none\"","marks":[{"type":"code"}]},{"type":"text","text":", waga 600"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"typography.button","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"cienie (elevation 1–24)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"obramowania 1 px, "},{"type":"text","text":"elevation: 0","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"MuiPaper","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"MuiCard","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"MuiAppBar","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"fala ripple po kliknięciu"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"wyraźny focus ring 2 px"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"MuiButtonBase","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"MuiButton","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"pola "},{"type":"text","text":"medium","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"pola "},{"type":"text","text":"small","marks":[{"type":"code"}]},{"type":"text","text":" – gęstszy panel"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"MuiTextField.defaultProps","marks":[{"type":"code"}]}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"krok-3-tryb-ciemny-bez-migotania"},"content":[{"type":"text","text":"Krok 3. Tryb ciemny bez migotania"}]},{"type":"paragraph","content":[{"type":"text","text":"Z motywem ze zmiennymi CSS tryb ciemny wymaga trzech rzeczy: "},{"type":"text","text":"ThemeProvider","marks":[{"type":"code"}]},{"type":"text","text":" z "},{"type":"text","text":"defaultMode","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"CssBaseline enableColorScheme","marks":[{"type":"code"}]},{"type":"text","text":" (paski przewijania i natywne pola też ciemnieją) oraz przełącznika opartego na "},{"type":"text","text":"useColorScheme()","marks":[{"type":"code"}]},{"type":"text","text":"."}]},{"type":"codeGroup","attrs":{"title":"Przełącznik trybu kolorów"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/components/ThemeModeToggle.tsx"},"content":[{"type":"text","text":"import DarkModeOutlined from \"@mui/icons-material/DarkModeOutlined\";\nimport LightModeOutlined from \"@mui/icons-material/LightModeOutlined\";\nimport SettingsBrightnessOutlined from \"@mui/icons-material/SettingsBrightnessOutlined\";\nimport ToggleButton from \"@mui/material/ToggleButton\";\nimport ToggleButtonGroup from \"@mui/material/ToggleButtonGroup\";\nimport { useColorScheme } from \"@mui/material/styles\";\n\nexport function ThemeModeToggle() {\n  const { mode, setMode } = useColorScheme(); // \"light\" | \"dark\" | \"system\", persisted in localStorage\n  if (!mode) return null; // not resolved yet on the very first render\n\n  return (\n    <ToggleButtonGroup\n      size=\"small\"\n      exclusive\n      value={mode}\n      onChange={(_, next: typeof mode | null) => next && setMode(next)}\n      aria-label=\"Colour scheme\"\n    >\n      <ToggleButton value=\"light\" aria-label=\"Light\">\n        <LightModeOutlined fontSize=\"small\" />\n      </ToggleButton>\n      <ToggleButton value=\"system\" aria-label=\"System\">\n        <SettingsBrightnessOutlined fontSize=\"small\" />\n      </ToggleButton>\n      <ToggleButton value=\"dark\" aria-label=\"Dark\">\n        <DarkModeOutlined fontSize=\"small\" />\n      </ToggleButton>\n    </ToggleButtonGroup>\n  );\n}"}]}]}]},"toc":[{"id":"krok-1-instalacja","text":"Krok 1. Instalacja","level":2,"locked":false},{"id":"krok-2-tokeny-projektowe-i-motyw","text":"Krok 2. Tokeny projektowe i motyw","level":2,"locked":false},{"id":"krok-3-tryb-ciemny-bez-migotania","text":"Krok 3. Tryb ciemny bez migotania","level":2,"locked":false},{"id":"krok-4-wlasne-komponenty-styled-sx-i-paleta-statusow","text":"Krok 4. Własne komponenty: styled, sx i paleta statusów","level":2,"locked":true},{"id":"krok-5-datagrid-tabela-po-stronie-klienta-i-serwera","text":"Krok 5. DataGrid: tabela po stronie klienta i serwera","level":2,"locked":true},{"id":"krok-6-formularz-react-hook-form-komponenty-mui","text":"Krok 6. Formularz: react-hook-form + komponenty MUI","level":2,"locked":true},{"id":"krok-7-skladamy-panel","text":"Krok 7. Składamy panel","level":2,"locked":true},{"id":"jak-uniknac-domyslnego-materiala-lista-kontrolna","text":"Jak uniknąć „domyślnego Materiala” – lista kontrolna","level":2,"locked":true},{"id":"typowe-bledy","text":"Typowe błędy","level":2,"locked":true},{"id":"sprawdz-sie","text":"Sprawdź się","level":2,"locked":true},{"id":"co-dalej","text":"Co dalej","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":57,"visibleBlocks":20,"resources":[{"id":"6b0857b53c96f2d34d0b39a6","type":"article","provider":"web","url":"https://martinfowler.com/articles/design-token-based-ui-architecture.html","embedUrl":null,"title":"Design Token-Based UI Architecture","description":"Describing established patterns for organizing design tokens and practical approaches for automation","author":"martinfowler.com","thumbnailUrl":"https://martinfowler.com/articles/design-token-based-ui-architecture/card.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["software-architecture","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2024-12-17T22:04:26.000Z","popularity":65,"verifiedAt":"2026-11-26T11:19:38.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857cc3c96f2d34d0b4cd9","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=XcI81nVWmWU","embedUrl":"https://www.youtube-nocookie.com/embed/XcI81nVWmWU","title":"Design systems for every user including people and LLMs | ODSP916","description":"Accessibility is often viewed as a usability feature or compliance requirement, important but secondary. In AI‑driven systems, that no longer holds. LLMs interpret the content we produce, and their reliability depends on structure, semantics, and clarity. Accessible content is easier for humans…","author":"Microsoft Developer","thumbnailUrl":"https://i.ytimg.com/vi/XcI81nVWmWU/hqdefault.jpg","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["llm","ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-06-03T10:44:45.000Z","popularity":36,"verifiedAt":"2026-11-26T10:56:19.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:15.892Z","updatedAt":"2026-11-26T16:01:15.892Z"},{"id":"6b0857b23c96f2d34d0b35c8","type":"repo","provider":"github","url":"https://github.com/danilowoz/react-atomic-design","embedUrl":null,"title":"danilowoz/react-atomic-design","description":"🔬 How the Atomic Design methodology can create a great design system from scratch and make better developers.","author":"danilowoz","thumbnailUrl":"https://opengraph.githubassets.com/1/danilowoz/react-atomic-design","durationSec":null,"lang":"en","topics":[],"techs":["javascript"],"tags":["atomic-css","atomic-design","boilerplate","css-architecture","css-modules","design-patterns","software-architecture","flowtype","react","storybook"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2017-11-05T17:19:08.000Z","popularity":63,"verifiedAt":"2026-11-26T10:57:25.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:50.215Z","updatedAt":"2026-11-26T16:00:50.215Z"},{"id":"6b0857c53c96f2d34d0b479b","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL24207531W","embedUrl":null,"title":"React Design Patterns and Best Practices","description":"","author":"Carlos Santana Roldan","thumbnailUrl":"https://covers.openlibrary.org/b/id/10653332-L.jpg","durationSec":null,"lang":"en","topics":[],"techs":["javascript"],"tags":["book","design-patterns"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2019-01-01T00:00:00.000Z","popularity":24,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:07.480Z","updatedAt":"2026-11-26T16:01:07.480Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[],"prev":null,"next":null,"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":68,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Autorytet","articles":63},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Autorytet","articles":53},{"key":"python","title":"Python","level":5,"levelLabel":"Autorytet","articles":52},{"key":"java","title":"Java","level":5,"levelLabel":"Autorytet","articles":38}]}}