Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tailwind-like props for margin and padding #583

Closed
wants to merge 1 commit into from

Conversation

vadimdemedes
Copy link
Owner

This PR adds shorthand props for margin and padding that are similar to Tailwind:

  • marginm
  • marginXmx
  • marginYmy
  • marginTopmt
  • marginBottommb
  • marginLeftml
  • marginRightmr
<Box mt={2}>Top</Box>
<Box mb={2}>Bottom</Box>
<Box ml={2}>Left</Box>
<Box mr={2}>Right</Box>
<Box mx={2}>Left and right</Box>
<Box my={2}>Top and bottom</Box>
<Box m={2}>Top, bottom, left and right</Box>
  • paddingp
  • paddingXpx
  • paddingYpy
  • paddingToppt
  • paddingBottompb
  • paddingLeftpl
  • paddingRightpr
<Box pt={2}>Top</Box>
<Box pb={2}>Bottom</Box>
<Box pl={2}>Left</Box>
<Box pr={2}>Right</Box>
<Box px={2}>Left and right</Box>
<Box py={2}>Top and bottom</Box>
<Box p={2}>Top, bottom, left and right</Box>

I think margin and padding-related props are among the most used ones and these shorthands should make it more convenient to use them.

@sindresorhus
Copy link
Collaborator

This kind of abbreviation is the one thing I don't like about Tailwind personally. Code should be written for readability. I don't know about VS Code, but Xcode would let me write <Box mt to get an autocomplete for <Box marginTop. So this could actually be resolved in the editor instead of ruining the code readability. There's also a big difference with Tailwind, Ink has far fewer properties and you can put properties on newlines, so there's less reason to optimize for conciseness.

@sindresorhus
Copy link
Collaborator

Works in VS Code too:

Screenshot 2023-05-02 at 18 04 50

@vadimdemedes
Copy link
Owner Author

Ok, good points.

@vadimdemedes vadimdemedes deleted the laudable-nancy-wheeler branch May 2, 2023 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants