All Projects → diegohaz → Styled Theme

diegohaz / Styled Theme

Licence: mit
Extensible theming system for styled-components 💅

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Styled Theme

Styled Components Rhythm
Vertical Rhythm and Font Baselines with Styled Components
Stars: ✭ 76 (-58.47%)
Mutual labels:  font, styled-components, css-in-js
Nanostyled
A <1kB library for styling React components as if with CSS-in-JS, without CSS-in-JS
Stars: ✭ 104 (-43.17%)
Mutual labels:  styled-components, css-in-js
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+1036.07%)
Mutual labels:  styled-components, css-in-js
Xstyled
A utility-first CSS-in-JS framework built for React. 💅👩‍🎤⚡️
Stars: ✭ 1,835 (+902.73%)
Mutual labels:  styled-components, css-in-js
React Image Smooth Loading
[not maintained] Images which just flick to appear aren't cool. Images which appear smoothly with a fade like Instagram are cool
Stars: ✭ 84 (-54.1%)
Mutual labels:  styled-components, css-in-js
Onno
Responsive style props for building themed design systems
Stars: ✭ 95 (-48.09%)
Mutual labels:  styled-components, css-in-js
Styled By
Simple and powerful lib to handle styled props in your components
Stars: ✭ 122 (-33.33%)
Mutual labels:  styled-components, css-in-js
Cabana React
A design system built especially for both Sketch and React. 💎⚛️
Stars: ✭ 58 (-68.31%)
Mutual labels:  styled-components, css-in-js
React Next Boilerplate
🚀 A basis for reducing the configuration of your projects with nextJS, best development practices and popular libraries in the developer community.
Stars: ✭ 129 (-29.51%)
Mutual labels:  styled-components, css-in-js
Next Dark Mode
🌑 Enable dark mode for Next.js apps
Stars: ✭ 133 (-27.32%)
Mutual labels:  styled-components, css-in-js
Goober
🥜 goober, a less than 1KB 🎉 css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+1166.12%)
Mutual labels:  styled-components, css-in-js
Horror
😱 React HTML elements with CSS-in-JS
Stars: ✭ 78 (-57.38%)
Mutual labels:  styled-components, css-in-js
Gatsby Theme Superstylin
💅 A Gatsby Theme with styled-components
Stars: ✭ 165 (-9.84%)
Mutual labels:  styled-components, css-in-js
Css In React
🍭 CSS in React - Learn the best CSS in JS frameworks by example
Stars: ✭ 101 (-44.81%)
Mutual labels:  styled-components, css-in-js
Tailwind Styled Component
Create Tailwind CSS React components like styled components with class names on multiple lines and conditional class rendering
Stars: ✭ 57 (-68.85%)
Mutual labels:  styled-components, css-in-js
Styled Typography
Typograpy components for react and styled-components
Stars: ✭ 113 (-38.25%)
Mutual labels:  styled-components, css-in-js
Styled Theming
Create themes for your app using styled-components
Stars: ✭ 1,067 (+483.06%)
Mutual labels:  styled-components, css-in-js
Atomize
library for creating atomic react components
Stars: ✭ 54 (-70.49%)
Mutual labels:  styled-components, css-in-js
Scoped Style
A tiny css in js library 🚀
Stars: ✭ 129 (-29.51%)
Mutual labels:  styled-components, css-in-js
Styled Bootstrap
💅🏻 A styled-component implementation of Bootstrap
Stars: ✭ 154 (-15.85%)
Mutual labels:  styled-components, css-in-js

styled-theme 💅🏿

Generated with nod NPM version Build Status Coverage Status

Theming system for styled-components 💅

Install

$ npm install --save styled-theme

Usage

Play with it on WebpackBin

import styled from 'styled-components'
import { font, palette } from 'styled-theme' 

const Text = styled.span`
  font-family: ${font('primary')};
  background-color: ${palette(1)};
  color: ${palette('grayscale', 0, true)};
`

Text.defaultProps = {
  palette: 'primary'
}
<Text>Hello</Text>

image

<Text reverse>Hello</Text>

image

<Text palette="secondary">Hello</Text>

image

Provide your own theme

import { ThemeProvider } from 'styled-components'

const xmasTheme = {
  fonts: {
    primary: 'Georgia, serif'
  },
  palette: {
    // red gradient
    primary: ['#D32F2F', '#F44336', '#F8877F', '#FFCDD2']
  }
}

<ThemeProvider theme={xmasTheme}>
  <Text>Hello</Text>
</ThemeProvider>

image

Default theme structure

This is the content of src/theme.js:

import coolorsToHex from 'coolors-to-hex'
import { reversePalette } from './composer'

const theme = {}

theme.palette = {
  primary: coolorsToHex('https://coolors.co/1976d2-2196f3-71bcf7-97cef9-c2e2fb'),
  secondary: coolorsToHex('https://coolors.co/c2185b-e91e63-f06292-f48caf-f8bbd0'),
  danger: coolorsToHex('https://coolors.co/d32f2f-f44336-f8877f-f9a7a1-ffcdd2'),
  alert: coolorsToHex('https://coolors.co/ffa000-ffc107-ffd761-ffecb3-fff2ce'),
  success: coolorsToHex('https://coolors.co/388e3c-4caf50-7cc47f-9fd4a1-c8e6c9'),
  grayscale: ['#212121', '#616161', '#9e9e9e', '#bdbdbd', '#e0e0e0', '#ffffff']
}

theme.reversePalette = reversePalette(theme.palette)

theme.fonts = {
  primary: 'Helvetica Neue, Helvetica, Roboto, sans-serif',
  pre: 'Consolas, Liberation Mono, Menlo, Courier, monospace',
  quote: 'Georgia, serif'
}

theme.sizes = {
  maxWidth: '1100px'
}

export default theme

reversePalette is a helper method. Import it from styled-theme/composer.

API

reversePalette

Revert the palette

Parameters

Examples

reversePalette({ primary: ['red', 'yellow', 'green'] })
// { primary: ['green', 'yellow', 'red'] }

Returns Palette

key

Returns the value of props.theme[path] or styledTheme[path]

Parameters

Examples

const Button = styled.button`
 font-family: ${key('fonts.primary')};
 color: ${key(['colors', 'primary', 0])};
`

Returns any

font

Shorthand to key(['fonts', path])

Parameters

  • path string
  • defaultValue any

Examples

const Button = styled.button`
 font-family: ${font('primary')};
`

Returns Font

size

Shorthand to key(['sizes', path])

Parameters

  • path string
  • defaultValue any

Examples

const Button = styled.button`
 padding: ${size('padding')};
`

Returns Size

palette

Returns the value of props.theme[palette || reversePalette][path][index] or styledTheme[palette || reversePalette][path][index] (default theme)

The arguments can be passed in any order, as long as types are kept.

Parameters

  • index number The index of tone in theme palette tones array
  • path string? The key of the tones in theme palette object (optional, default props.palette)
  • exceptions Object? An object with path as key and index as value
  • reverse boolean? Flag to return tone from reversePalette or palette
  • defaultValue string? Default value
  • args ...any

Examples

// index = 1
// exception = { grayscale: 0 }
// reverse = true
const Button = styled.button`
 background-color: ${palette({ grayscale: 0 }, 1, true)};
`

// renders props.theme.reversePalette.grayscale[0]
<Button palette="grayscale" />

// renders props.theme.palette.danger[1] (nullify reverse)
<Button palette="danger" reverse />

Returns Tones

Tone

Type: string

Tones

Type: Tone>

Font

Type: string

Size

Type: string

Palette

Type: {}

Fonts

Type: {}

Sizes

Type: {}

Theme

Type: {palette: Palette?, reversePalette: Palette?, fonts: Fonts?, sizes: Sizes?}

Related

  • styled-tools - Utilities for styled-components (like lodash)

License

MIT © Diego Haz

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].