Aesthetic
Aesthetic is a powerful type-safe, framework agnostic, CSS-in-JS library for styling components,
whether it be with plain objects, importing style sheets, or simply referencing external class
names. Simply put, Aesthetic is an abstraction layer for the compilation of styles via third-party
libraries, all the while providing customizability, theming, additional features, and a unified
syntax.
import AphroditeAesthetic from 'aesthetic-adapter-aphrodite';
import { Theme } from './types';
const aesthetic = new AphroditeAesthetic<Theme>();
aesthetic.registerTheme('light', {
unit: 8,
});
aesthetic.registerStyleSheet('button', ({ unit }) => ({
button: {
textAlign: 'center',
display: 'inline-block',
padding: unit,
},
}));
const styles = aesthetic.createStyleSheet('button');
const className = aesthetic.transformStyles(styles.button);
React
Supports both an HOC and hook styled React API!
import React from 'react';
import useStyles from './useStyles';
export type Props = {
children: React.ReactNode;
};
export default function Button({ children }: Props) {
const [styles, cx] = useStyles(({ unit }) => ({
button: {
textAlign: 'center',
display: 'inline-block',
padding: unit,
},
}));
return (
<button type="button" className={cx(styles.button)}>
{children}
</button>
);
}
Requirements
Installation
yarn add aesthetic
// Or
npm install aesthetic
Documentation
https://milesj.gitbook.io/aesthetic