Home

Awesome

<p align="center"> <img src='https://i.imgur.com/5fgTysV.jpg' alt='Tetrahedron Logo'/> </p> <p align="center"> <a href="https://travis-ci.org/tetrahedron/core"> <img src="https://travis-ci.org/tetrahedron/core.svg?branch=master" alt="Travis CI build status"> </a> <a href="https://github.com/tetrahedron/core/blob/master/LICENSE"> <img src="https://img.shields.io/github/license/tetrahedron/core.svg" alt="License"> </a> <a href="https://npm.im/@tetrahedron/core"> <img src="https://img.shields.io/bundlephobia/minzip/@tetrahedron/core.svg" alt="gzip size"> </a> <a href="https://spectrum.chat/tetrahedron"> <img src="https://withspectrum.github.io/badge/badge.svg" alt="Join the community on Spectrum"> </a> </p>

Tetrahedron Core

Tetrahedron Core is a collection of components that are frequently used by the sub-packages in Tetrahedron UI.

Quick Jump

  1. Installation
  2. Documentation
    1. Stylable

Installation

Using yarn

yarn add @tetrahedron/core

Using npm

npm install @tetrahedron/core

Documentation

Stylable

Stylable is a function that returns a styled-components component that has all of the most commonly set CSS properties exposed as react properties.

Props

Usage

<details><summary><strong>Basic Usage</strong></summary><p>

This is not something that you will use as a react component, but rather as a complement to styled-components. It's a function that accepts a single string argument (tagname). Most every html tag is supported, you can find a list of html tags here.

Here's an example of basic usage

import React from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";

const CustomComponent = Stylable("div");

const App = () => (
  <CustomComponent padding="20px" background="palevioletred" color="white">
    This is my custom styled component!
  </CustomComponent>
);

ReactDOM.render(<App />, document.getElementById("root"));
</p></details> <details><summary><strong>With styled-components</strong></summary><p>

You can also combine the Stylable function with styled to set an initial style via styled-components, while still allowing style changes inline. This is especially useful if you want to create a reusable component that will allow tweaking on the fly.

import React from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";

const CustomComponent = styled(Stylable("div"))`
  font-size: 30px;
  font-family: sans-serif;
`;

const App = () => (
  <CustomComponent padding="20px" background="palevioletred" color="white">
    This is my custom styled component!
  </CustomComponent>
);

ReactDOM.render(<App />, document.getElementById("root"));
</p></details>

Credits

Tetrahedron Core is a project by Garet McKinley

Want to help? Join our Spectrum.chat community to get started!

License

MIT