Skip to content

Add marginX/marginY and paddingX/paddingY to the style attributes#619

Merged
simonklee merged 5 commits intoanomalyco:mainfrom
viralcodex:padding-and-margin-X-and-Y
Feb 4, 2026
Merged

Add marginX/marginY and paddingX/paddingY to the style attributes#619
simonklee merged 5 commits intoanomalyco:mainfrom
viralcodex:padding-and-margin-X-and-Y

Conversation

@viralcodex
Copy link
Contributor

@viralcodex viralcodex commented Feb 2, 2026

Fixes: #618

Hi team,

Here's a small change that I have added.
X and Y attributes for both padding and margin just to make writing these values a little easier.

This is my first PR on this project and I am using this project for my own CLI tool I am building.

We can discuss and see if it fits with the project requirements.

But from a Dev experience point of view, I felt like I should add it to make it better, Also this aligns with people accustomed to tailwindCSS as well.

Here's a small demo:

Screen.Recording.2026-02-02.at.5.04.34.PM.mov

Introduce horizontal/vertical shorthand properties for margins and padding. Update LayoutOptions to include marginX, marginY, paddingX and paddingY; apply them in setOptions to set both corresponding Yoga edges; add instance setters that update the Yoga node and request a render. Add unit tests verifying acceptance of number, auto/percent (where applicable), null and undefined for each new property.
@viralcodex viralcodex changed the title Add marginX/marginY and paddingX/paddingY setters Add marginX/marginY and paddingX/paddingY to the style attributes Feb 2, 2026
@kommander
Copy link
Collaborator

Hi, I think that's fine to add as convenience and it's only additive to the API, so shouldn't be an issue. Now that we have proper docs for the website, maybe we could directly document that there as well?

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 3, 2026

@opentui/core

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core@3a4383d

@opentui/react

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/react@3a4383d

@opentui/solid

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/solid@3a4383d

@opentui/core-darwin-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-arm64@3a4383d

@opentui/core-darwin-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-darwin-x64@3a4383d

@opentui/core-linux-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-arm64@3a4383d

@opentui/core-linux-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-linux-x64@3a4383d

@opentui/core-win32-arm64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-arm64@3a4383d

@opentui/core-win32-x64

npm i https://pkg.pr.new/anomalyco/opentui/@opentui/core-win32-x64@3a4383d

commit: 3a4383d

@viralcodex
Copy link
Contributor Author

Hi @kommander, sure I can add it there as well, not an issue

Update layout to include axis-specific spacing properties (paddingX, paddingY, marginX, marginY) in the docs.
@viralcodex
Copy link
Contributor Author

@kommander, added in the docs, please let me know if I have missed something or something else is needed/changed.

Thanks 😄

Copy link
Collaborator

@simonklee simonklee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@simonklee simonklee merged commit db2c397 into anomalyco:main Feb 4, 2026
6 checks passed
simonklee added a commit to simonklee/opentui that referenced this pull request Feb 4, 2026
I noticed when reviewing anomalyco#619
that Yoga supports Edge.All, Edge.Horizontal, and Edge.Vertical to set
multiple edges in a single call. Use these instead of calling setMargin
or setPadding four times for uniform values or twice for axis values.
simonklee added a commit that referenced this pull request Feb 4, 2026
I noticed when reviewing #619
that Yoga supports Edge.All, Edge.Horizontal, and Edge.Vertical to set
multiple edges in a single call. Use these instead of calling setMargin
or setPadding four times for uniform values or twice for axis values.

Co-authored-by: Matt Simpson <7691252+msmps@users.noreply.github.com>
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.

feat: have paddingX/paddingY and marginX/marginY

3 participants