JSFiddle - React, Tailwind, and code Playground

by LyndseyB

JavaScript

const theme = {
	buttons: {
    borderSize: "1px",
    borderColor: "red",
    borderType: "solid"
  }
};

const getThemedProp = prop => (...keys) => keys.reduce((cssString, key) => `${cssString} ${theme[prop][key]}`, "");

const setThemeProp = getThemedProp("buttons")

console.log(`border:${setThemeProp("borderSize", "borderColor")}`);