styled-themer
Utility function to select a theme element from a styled components theme
Installation
npm i styled-themer
Usage
The simplest way to use styled-themer
is via the default import t
, which can be used to select a particular theme element as follows:
;; // Normal wayconst Text1 = styledspan` color: ;`; // Using styled-themerconst Text2 = styledspan` color: ;`;
Apart from this, there are also shorthands color
, bgColor
and fontSize
to further reduce the amount of code required.
;; // Normal wayconst Wrapper = styleddiv` color: ; background-color: ; font-size: ;`; // Using styled-themerconst Wrapper22 = styledspan` ; ; ;`;
color
and bgColor
select the given key from theme.color
, and add the CSS property (color:
and background-color:
) as a prefix.