Skip to content

Having trouble setting negative margins #1241

Answered by atanasster
danchristian asked this question in Q&A
Discussion options

You must be logged in to vote

@danchristian , one way would be to use a function resolver for the property:

/** @jsx jsx */
import { jsx, get } from "theme-ui";

export const Columns = ({ space, children }) => {
  return (
    <div
      sx={{
        display: "flex",
        flexDirection: "row",
        marginLeft: (t) => -get(t, `space.${space}`, space),
        "> div": { paddingLeft: space }
      }}
    >
      {children}
    </div>
  );
};

full cs: https://codesandbox.io/s/goofy-cache-9wwri?file=/src/components/Columns.js

Replies: 3 comments 4 replies

Comment options

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

Answer selected by danchristian
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@atanasster
Comment options

@hasparus
Comment options

@danchristian
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants