Skip to content

Instantly share code, notes, and snippets.

@GeorgeTaveras1231
Last active July 3, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeorgeTaveras1231/1bc5990cec90041039543080c4871c7e to your computer and use it in GitHub Desktop.
Save GeorgeTaveras1231/1bc5990cec90041039543080c4871c7e to your computer and use it in GitHub Desktop.

Ways to use union styles

CSS Classes with composes

This approach requires that you compose a union class and extend your own class with custom styles.

Example

CSS:

.myClass {
  composes: hero from '@xo-union/tk-ui-typography/lib/css/font-scale-categories';
  /* Custom styles */
  color: red;
}

JS:

import { myClass } from './styles.css';

const MyComponent = () => {
  return <div className={myClass}>Text</div>
}

export default MyComponent;

React Component

This approach requires that you just import a component for a standard element. You will still need to write your own class to extend the styles of the underlying element.

Example

CSS:

.myClass {
  color: red
}

JS:

import { Hero } from '@xo-union/tk-ui-typography';
import { myClass } from './styles.css';

const MyComponent = () => {
  return <Hero className={myClass}>Text</Hero>
}

export default MyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment