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

Text preferred html component prop #2735

Closed
1 task done
zsoltbokor opened this issue Nov 9, 2024 · 1 comment
Closed
1 task done

Text preferred html component prop #2735

zsoltbokor opened this issue Nov 9, 2024 · 1 comment
Labels
enhancement Requires extension or creation of new React Native API

Comments

@zsoltbokor
Copy link

zsoltbokor commented Nov 9, 2024

Is there an existing request?

  • I have searched for this request

Describe the feature request

Currently there is a logic in the Text component to decide what html component to be rendered.
So it can render div, span, a.

On a website a text can have role title, subtitle, paragraph etc.

Idea: Extend TextProps so include a new property preferredHTMLElement. Then if the Text will be used as title on a page it can get H1, H2 etc. That could help to boost SEO.

Alternative solution: use data attribute, e.g data-html-element (CON: can't limit the possible values)

Usage example:

 <View>
    <Text preferredHTMLElement="h1">I am the title</Text>
     <Text preferredHTMLElement="h2">I am the sub-title</Text>
     
      <Text preferredHTMLElement="p">I am just a paragraph</Text>
 </View>
@zsoltbokor zsoltbokor added the enhancement Requires extension or creation of new React Native API label Nov 9, 2024
@necolas
Copy link
Owner

necolas commented Nov 9, 2024

You can use the relevant role and aria-level to render headings

@necolas necolas closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requires extension or creation of new React Native API
Projects
None yet
Development

No branches or pull requests

2 participants