Skip to content

General question about authoring styles versus components #587

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

You must be logged in to vote

Nicolas's comment was specifically against the "styled-components" way of doing things where every div with custom styles is turned into a custom component. Don't do that. Other than that, continue to create components that accepts props or styles as props and apply styles conditionally.

The example you've provided above is fine. But something like this would also be idiomatic:

import * as stylex from "@stylexjs/stylex";
import { vars } from "../../styles/vars.stylex";

const styles = stylex.create({
  base: {
    alignItems: "center",
    blockSize: vars.buttonBlockSize,
    borderRadius: 1e3,
    display: "flex",
    gap: 8,
    justifyContent: "center",
    paddingInline: 16,
  },
  pr…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by zaydek
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