Skip to content

Conversation

@armaan-ghosh
Copy link

Background

Issue: #21094

Developers have been intuitively nesting <s-icon> and <s-badge> components inside <s-text>, expecting them to align with the text baseline. However, this causes visible vertical misalignment (originally reported in #19011).

Root cause: React Native's Text component fundamentally does not support baseline alignment for nested View components. Since Icon renders as an SVG View and Badge renders as HStack→Box→Badge, they float without proper vertical positioning when nested inside Text.

Solution

Updated the Text component documentation to prevent this common mistake by:

  1. Best Practices section - Added guidance to use Stack with direction="inline" when combining text with icons or badges, rather than nesting components inside Text

  2. Limitations section - Added clear explanation of the React Native alignment limitation with nested Icon/Badge components, including the recommended Stack alternative pattern

This is a documentation-only change that guides developers toward the correct pattern without requiring code changes or impacting performance.

- Add best practice: Use Stack for icons and badges instead of nesting
- Add limitation: Explain React Native alignment issue with nested Icon/Badge
- Provide Stack with direction='inline' as recommended alternative

Addresses #21094
@armaan-ghosh armaan-ghosh force-pushed the ag/text-icon-badge-docs-warning branch from f40a60b to fbeefc2 Compare December 16, 2025 21:10
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