Skip to content

docs: add tw.style() array pattern guidance to styling rule#974

Merged
georgewrmarshall merged 3 commits into
mainfrom
styling-cursor-rule-update
Mar 23, 2026
Merged

docs: add tw.style() array pattern guidance to styling rule#974
georgewrmarshall merged 3 commits into
mainfrom
styling-cursor-rule-update

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Description

Extracts and documents the React Native tw.style() array pattern from the BannerAlert migration (PR #966) into the styling cursor rule. This pattern is essential for components that need to apply Tailwind classes while accepting a custom style prop.

What is the reason for the change?

  • The BannerAlert component migration introduced an important pattern for merging tw.style() with style props using arrays
  • This pattern ensures type safety and proper merge order (tw classes → twClassName → style prop)
  • The pattern needs to be documented in the styling rule so it's available as a reference for all future components

What is the improvement/solution?

  • Adds comprehensive documentation of the array pattern to .cursor/rules/styling.md
  • Includes correct ✅ and incorrect ❌ examples
  • Explains why the array pattern is preferred (type safety, merge order, consistency with Box)
  • Provides real-world example from BannerAlert component
  • Ensures AI agents and developers follow this pattern consistently

This documentation was originally added as part of PR #966 but is being extracted into a standalone documentation update for better visibility and reusability.

Related issues

Related to:

Manual testing steps

  1. Review the updated .cursor/rules/styling.md file
  2. Verify the array pattern documentation is clear and comprehensive
  3. Confirm examples match the BannerAlert implementation

Screenshots/Recordings

N/A - Documentation only change

Before

No documentation for merging tw.style() with style props

After

Comprehensive documentation including:

  • ❌ Wrong pattern (passing style directly to tw.style)
  • ✅ Correct pattern (array with tw.style and style)
  • Why array pattern explanation
  • Real-world BannerAlert example

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable (N/A - documentation only)
  • I've documented my code using JSDoc format if applicable (N/A)
  • I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Documentation-only update that doesn’t change runtime behavior; risk is limited to teams adopting the guidance incorrectly, but examples are explicit and type-safety oriented.

Overview
Adds new React Native styling guidance to .cursor/rules/styling.md documenting the tw.style() + style prop array pattern for components that need both Tailwind classes and a consumer-provided style.

Includes explicit ✅/❌ examples, rationale (type safety and keeping twClassName forwarded as a prop), and a concrete BannerAlert-based snippet showing the recommended merge order.

Written by Cursor Bugbot for commit dc3ce04. This will update automatically on new commits. Configure here.

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner March 10, 2026 20:22
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Left a comment

brianacnguyen
brianacnguyen previously approved these changes Mar 16, 2026
@georgewrmarshall georgewrmarshall enabled auto-merge (squash) March 16, 2026 16:25
@georgewrmarshall georgewrmarshall marked this pull request as draft March 16, 2026 16:26
auto-merge was automatically disabled March 16, 2026 16:26

Pull request was converted to draft

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall marked this pull request as ready for review March 22, 2026 17:27
@georgewrmarshall georgewrmarshall enabled auto-merge (squash) March 22, 2026 17:27
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall georgewrmarshall self-assigned this Mar 23, 2026
@georgewrmarshall georgewrmarshall merged commit b843b0b into main Mar 23, 2026
44 checks passed
@georgewrmarshall georgewrmarshall deleted the styling-cursor-rule-update branch March 23, 2026 16:28
georgewrmarshall added a commit that referenced this pull request Apr 27, 2026
## **Description**

Extracts and documents the React Native `tw.style()` array pattern from
the BannerAlert migration (PR #966) into the styling cursor rule. This
pattern is essential for components that need to apply Tailwind classes
while accepting a custom `style` prop.

**What is the reason for the change?**
- The BannerAlert component migration introduced an important pattern
for merging `tw.style()` with style props using arrays
- This pattern ensures type safety and proper merge order (tw classes →
twClassName → style prop)
- The pattern needs to be documented in the styling rule so it's
available as a reference for all future components

**What is the improvement/solution?**
- Adds comprehensive documentation of the array pattern to
`.cursor/rules/styling.md`
- Includes correct ✅ and incorrect ❌ examples
- Explains why the array pattern is preferred (type safety, merge order,
consistency with Box)
- Provides real-world example from BannerAlert component
- Ensures AI agents and developers follow this pattern consistently

This documentation was originally added as part of PR #966 but is being
extracted into a standalone documentation update for better visibility
and reusability.

## **Related issues**

Related to:
- #966
(BannerAlert migration)

## **Manual testing steps**

1. Review the updated `.cursor/rules/styling.md` file
2. Verify the array pattern documentation is clear and comprehensive
3. Confirm examples match the BannerAlert implementation

## **Screenshots/Recordings**

N/A - Documentation only change

### **Before**

No documentation for merging `tw.style()` with style props

### **After**

Comprehensive documentation including:
- ❌ Wrong pattern (passing style directly to tw.style)
- ✅ Correct pattern (array with tw.style and style)
- Why array pattern explanation
- Real-world BannerAlert example

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs)
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable (N/A - documentation only)
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable (N/A)
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk because this PR only updates documentation and adds no
runtime code changes.
> 
> **Overview**
> Documents a React Native **array-based merge pattern** for combining
component `tw.style()` classes with a passed-in `style` prop, while
keeping `twClassName` forwarded separately.
> 
> Adds do/don’t examples, rationale (type-safety and consistent merge
behavior), and a `BannerAlert` snippet illustrating the recommended
approach.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
de51983. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

2 participants