Skip to content

Instantly share code, notes, and snippets.

@Marcisbee
Last active September 18, 2020 21:23
Show Gist options
  • Save Marcisbee/510d89f4aa2c073a2434816393d79f8c to your computer and use it in GitHub Desktop.
Save Marcisbee/510d89f4aa2c073a2434816393d79f8c to your computer and use it in GitHub Desktop.
Idea of CSS in JS lib syntax
import { css, hover, setTheme, theme } from 'csx';
import { dark, light } from './themes';
setTheme(light);
const highlight = css({
color: 'red',
backgroundColor: theme.background,
hover: {
color: 'orangered',
},
});
function App() {
return (
<div>
<h1 className={highlight}>
Hello world
</h1>
<button onClick={() => setTheme(dark)}></button>
</div>
);
}
export const dark = {
background: '#333',
};
export const light = {
background: '#fff',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment