Skip to content

Allow nested objects within stylex.create for importing purposes #21

@Rynebenson

Description

@Rynebenson

I would like to define styles once and import throughout my app.

[styles.js]
import { margin } from './margin'

const styles = stylex.create({
  margin
});

export default styles
[margin.js]
export const margin = {
  micro: {
    margin: 4
  },
  small: {
    margin: 8
  },
  top: {
    micro: {
      marginTop: 4
    },
    small: {
      marginTop: 8
    }
  }
}
[component.js]
import styles from './styles'

function Component() {
  return (
    <div className={stylex(styles.margin.small)}>
      <button className={stylex(styles.margin.top.micro)}>
        Click Me!
      </button>
    </div>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions