customizing-styles.mdx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Customizing Styles
  2. Excalidraw is using CSS variables to style certain components. To override them, you should set your own on the `.excalidraw` and `.excalidraw.theme--dark` (for dark mode variables) selectors.
  3. Make sure the selector has higher specificity, e.g. by prefixing it with your app's selector:
  4. ```css
  5. .your-app .excalidraw {
  6. --color-primary: red;
  7. }
  8. .your-app .excalidraw.theme--dark {
  9. --color-primary: pink;
  10. }
  11. ```
  12. Most notably, you can customize the primary colors, by overriding these variables:
  13. - `--color-primary`
  14. - `--color-primary-darker`
  15. - `--color-primary-darkest`
  16. - `--color-primary-light`
  17. - `--color-primary-contrast-offset` — a slightly darker (in light mode), or lighter (in dark mode) `--color-primary` color to fix contrast issues (see [Chubb illusion](https://en.wikipedia.org/wiki/Chubb_illusion)). It will fall back to `--color-primary` if not present.
  18. For a complete list of variables, check [theme.scss](https://github.com/excalidraw/excalidraw/blob/master/src/css/theme.scss), though most of them will not make sense to override.
  19. ```css showLineNumbers
  20. .custom-styles .excalidraw {
  21. --color-primary: #fcc6d9;
  22. --color-primary-darker: #f783ac;
  23. --color-primary-darkest: #e64980;
  24. --color-primary-light: #f2a9c4;
  25. }
  26. .custom-styles .excalidraw.theme--dark {
  27. --color-primary: #d494aa;
  28. --color-primary-darker: #d64c7e;
  29. --color-primary-darkest: #e86e99;
  30. --color-primary-light: #dcbec9;
  31. }
  32. ```
  33. ```tsx live
  34. function App() {
  35. return (
  36. <div style={{ height: "500px" }} className="custom-styles">
  37. <Excalidraw />
  38. </div>
  39. );
  40. }
  41. ```