All Projects → c8r → Vue Styled System

c8r / Vue Styled System

Licence: mit
Design system utilities wrapper for Vue components, based on styled-system

Programming Languages

javascript
184084 projects - #8 most used programming language

vue-styled-system Build Status js-standard-style

Design system utilities for Vue based on styled-system.

Installation

npm i -S vue-styled-system

Usage

Passing theme context to components

In order to allow components to access the theme, you can declare a global mixin using withTheme.

import Vue from 'vue'
import { withTheme } from 'vue-styled-system'
import theme from './theme.json'

Vue.mixin(withTheme(theme))
Adding styled-system props

Since Vue requires all props to be defined, you can call the default function to assign all props that are missing defaults:

import { color, space, fontSize, width } from 'styled-system'
import styled from 'vue-styled-components'
import system from 'vue-styled-system'
import theme from './theme.json'

export default styled('button', system({
  px: { default: 4 },
  py: { default: 2 },
  color: { default: 'white' },
  bg: { default: 'blue' },
  theme: { default: theme }
}))`
  display: inline-block;
  font-family: inherit;
  border-width: 0px;
  border-radius: 4px;
  appearance: none;
  ${color}
  ${space}
  ${fontSize}
  ${width}
`

License

MIT

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Made by Compositor | MIT License

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].