Skip to content

Add styled-jsx documentation  #641

Open
@jpt

Description

@jpt

Hi! Love this library. According to the docs here, there is support for CSS Modules, Radium, Aphrodite, JSS, Inline styles, and global CSS -- but not styled-jsx (popular amongst Next.js users), which is what we use at Shift.org. One of our engineers came up with a great solution for using styled-jsx along with react-autocomplete.

I could add to the docs here and submit a PR, or I could submit the PR to react-themeable -- probably both? Seems related to #400. In either case, I bet it's a common enough use case that it's worth documenting.

Here's a snippet using react-autosuggest__suggestions-container--open as an example class being custom themed using styled-jsx.

style.js:

import css from 'styled-jsx/css';

const color = 'blue';

const {
  className: suggestionsContainerOpen,
  styles: suggestionsContainerOpenStyles,
} = css.resolve`
    border: 1px solid ${color};
`;

export default {
  theme: {
    suggestionsContainerOpen,
  },
  styles: [
    suggestionsContainerOpenStyles,
  ],
}

index.js:

import Autosuggest from 'react-autosuggest';
import style from './style';
...

return (
  <React.Fragment>
    <Autosuggest
      theme={style.theme}
      ...
    />
    {style.styles.map(styleObj => styleObj)}
  </React.Fragment>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions