Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@react-md/theme
Advanced tools
The base package for including a theme for react-md. This is required by most other packages.
This package is used for creating a color theme within react-md. It also exposes some utility Components and mixins for updating the theme at runtime through CSS Variables.
This package can be installed through npm
if you want access to all the SCSS
variables, functions, and mixins or by using the pre-compiled bundles hosted on
https://unpkg.com.
npm install --save @react-md/theme
Full usage and documentation can be found on the main documentation site at the theme page, but there will be a few examples in this README.
Starting with v2.0.0, react-md will use both SCSS and css variables to define themes. This allows you to use the nice dynamic themes with css variables in evergreen browsers but also support the older ones if needed.
The default theme is:
$rmd-theme-primary: $rmd-purple-500 !default;
$rmd-theme-secondary: $rmd-pink-a-400 !default;
// the background color for your app. Normally applied to the base <html> tag
$rmd-theme-background: #fafafa !default;
// the background color for "surfaces" (things like dialogs, menus, cards, etc)
$rmd-theme-surface: #fff !default;
This can be overridden by setting these variables to new colors that are
included in react-md, or a custom color by re-defining these values before
importing the main theme
file.
If you override the $rmd-theme-light
variable to be false
, the default theme
will be:
$rmd-theme-primary: $rmd-purple-500 !default;
$rmd-theme-secondary: $rmd-pink-a-400 !default;
// the background color for your app. Normally applied to the base <html> tag
$rmd-theme-background: #303030 !default;
// the background color for "surfaces" (things like dialogs, menus, cards, etc)
$rmd-theme-surface: $md-grey-800 !default;
If the theme colors are one of the material design colors, you can use some of the existing SCSS variables to update your theme.
Example:
@import "@react-md/theme/dist/color-palette";
$rmd-theme-primary: $rmd-blue-500;
$rmd-theme-secondary: $rmd-orange-a-400;
@import "@react-md/theme/dist/mixins";
@include react-md-theme;
Note that the theme variables were overridden before importing the main
theme
file. You might have problems overriding the theme if you define them
after.
Since your company might have specific branding colors, it is also possible to define a theme that does not have material design colors at all.
$my-awesome-company-purple: #9b59b6;
$my-awesome-company-orange: #e67e22;
$rmd-theme-primary: $my-awesome-company-purple;
$rmd-theme-secondary: $my-awesome-company-orange;
@import "@react-md/theme/dist/mixins";
@include react-md-theme;
To make including custom styles easy, it might be helpful to create the following files in your project:
src/_branding.scss
- A file that contains the color variables for your
company's brandingsrc/_react-md-overrides.scss
- A file that contains the react-md variable
overrides with new valuessrc/_all.scss
- A file that is used as a quick import to include all
available variables, mixins, and functions within any file in your app for
conveniencesrc/index.scss
- A file that is used to generate your base stylesExample:
// in src/_branding.scss
$my-awesome-company-purple: #9b59b6;
$my-awesome-company-orange: #e67e22;
// in src/_react-md-overrides.scss
@import "branding";
$rmd-theme-primary: $my-awesome-company-purple;
$rmd-theme-secondary: $my-awesome-company-orange;
// in src/_all.scss
@import "my-awesome-company-branding";
@import "my-awesome-company-react-md-overrides";
@import "@react-md/theme/dist/mixins";
// in src/index.scss
@import "all";
@include react-md-theme;
3.0.0 (2021-08-13)
This release should be relatively simple for most consumers of this library since the main breaking change is dropping support for node-sass
and requiring sass
since node sass has been deprecated as well as removing deprecated variables, hooks, and components.
Most users should be able to run the following commands to upgrade to v3.0.0:
npm update react-md
npm uninstall node-sass
npm install sass
Or with yarn
yarn add react-md
yarn remove node-sass
yarn add sass
In addition, there is now partial support for the new Sass module system with the react-md
package which also simplifies the import usage and has a slight build performance improvement for large projects.
To start using the new module system, update all the @import
statements as shown below:
-@import '~@react-md/theme/dist/mixins';
-@import '~@react-md/utils/dist/mixins';
-// other react-md imports
+@use 'react-md' as *;
// No other changes required!
If you override variables within react-md
:
-@import '~@react-md/theme/dist/color-palette';
-$rmd-theme-light: false;
-$rmd-theme-primary: $rmd-purple-500;
-$rmd-theme-secondary: $rmd-pink-a-200;
-
-@import '~react-md/dist/styles';
+@use '@react-md/theme/dist/color-palette' as color;
+@use 'react-md' as * with (
+ $rmd-theme-light: false,
+ $rmd-theme-primary: color.$rmd-theme-purple-500,
+ $rmd-theme-secondary: color.$rmd-theme-pink-a-200,
+);
+
+@include react-md-utils;
Check out the updated customizing your theme documentation, #1214, or 958f34f for more in-depth examples.
$rmd-theme-dark-elevation
now defaults to true
instead of false
node-sass
is no longer supported and users must switch to sass
InteractionModeListener
since it was an alias for UserInteractionModeListener
ResizeObserver
component and useResizeObserverV1
implementationTooltipHoverModeConfig
component$rmd-card-dark-elevation-bordered-background-color
variableTooltipped
componentuseIndeterminateChecked
is now an object of optionssass
since it's deprecated (126fb5a)defaults
to true (b371337)sass
usage with: @use 'react-md';
(787bfb5)@use
(68e8c6b)react-md/dist/_everything.scss
(c7177e6)sassdoc
and variables to use everything.scss (a0f0699)sass
(5376be1)useIndeterminateChecked
(6b7871f)Tooltipped
component (6dca9b1)typedoc
API in navigation tree (c388ba6)@use
imports (958f34f)defaults
(b2269ff)sass
instead of node-sass (d8ddf51)react-md
(c0f25f7)FAQs
The base package for including a theme for react-md. This is required by most other packages.
The npm package @react-md/theme receives a total of 1,749 weekly downloads. As such, @react-md/theme popularity was classified as popular.
We found that @react-md/theme demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.