Material Color

The theme defines a set of CSS custom properties you can use to apply a consistent color palette across your application.

Background

--material-background-color: #fff

--material-secondary-background-color: #f5f5f5

Text

The following text colors have the desired contrast with the main background color.

Note, that --material-primary-text-color is not necessarily the same as --material-primary-color. Use the main color for backgrounds and the “text” version for text. The same applies for the “error” and “success” colors as well.

The “disabled” text color does not have enough contrast by default to meet WCAG 2.0 AA level requirements (4.5:1). Only use it for text which is not crucial for the end user to see.

--material-body-text-color: rgba(0, 0, 0, 0.87)

--material-secondary-text-color: rgba(0, 0, 0, 0.54)

--material-disabled-text-color: rgba(0, 0, 0, 0.38)

--material-primary-text-color: #6200ee

--material-error-text-color: #b00020

Primary

The most prominent color in the theme. It is used to bring attention to certain elements in the interface. An accompanying contrast color is also defined.

--material-primary-color: #6200ee

--material-primary-contrast-color: #fff

Error

Usually a red color, used for things like error indicators, error messages and buttons that can cause permanent data loss.

--material-error-color: #b00020

Examples

Primary

HTML

  1. <span class="primary">Text</span>
  2. <custom-style>
  3. <style>
  4. .primary {
  5. background-color: var(--material-primary-color);
  6. color: var(--material-primary-contrast-color);
  7. }
  8. </style>
  9. </custom-style>

Error

HTML

  1. <span class="error"></span>
  2. <custom-style>
  3. <style>
  4. .error {
  5. background-color: var(--material-error-color);
  6. }
  7. </style>
  8. </custom-style>

Text

HTML

  1. <div class="base">
  2. <div class="body-text">Normal text</div>
  3. <div class="secondary-text">Secondary text</div>
  4. <div class="disabled-text">Disabled text</div>
  5. <div class="primary-text">Primary text</div>
  6. <div class="error-text">Error text</div>
  7. </div>
  8. <custom-style>
  9. <style>
  10. .body-text {
  11. color: var(--material-body-text-color);
  12. }
  13. .secondary-text {
  14. color: var(--material-secondary-text-color);
  15. }
  16. .disabled-text {
  17. color: var(--material-disabled-text-color);
  18. }
  19. .primary-text {
  20. color: var(--material-primary-text-color);
  21. }
  22. .error-text {
  23. color: var(--material-error-text-color);
  24. }
  25. </style>
  26. </custom-style>