Skip to content

StyleXStyles and Developer Experience / Documentation #537

Answered by nmn
BMCwebdev asked this question in Q&A
Discussion options

You must be logged in to vote

I’m trying to avoid dynamic styles for obvious reasons. Additionally a company-wide Content Security Policy may be enacted that will disallow inline styles.

Use StaticStyles instead of StyleXStyles and it will disallow dynamic styles and hence inline styles.

The component may be something that is constrained to accept only a width CSS property, but the value can be anything the consumer needs.

You can use string | number as the value type.

export interface AcmeBoxProps {
  userStyles?: StaticStyles<{
    width: string | number;
    gridTemplateColumns: string;
  }>
}

(You can add null if you want the ability to unset default styles as well)

The user will have to know that a style obj…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@nmn
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by BMCwebdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants