Similar to the Facebook React Native Text component and the JSX equivalent to aCYITextSceneNode
pointer from C++.
Unlike Facebook React Native’s Text, TextRef requires you to set your text as a prop.
Remember the following points when you use TextRef:
<Text>Sample Text</Text>
<Composition source="Assets_Text">
<TextRef name="RefText" text="Sample Text" />
</Composition>
TextRef also has limited support for styling. These styles override the information coming from After Effects.
<TextRef name="RefText" text="My ref text" style={{
color: 'red',
textAlign: 'center',
}}/>
import React, { Component } from 'react';
import { Composition, ViewRef, TextRef } from '@youi/react-native-youi';
export default class TextRefComponent extends Component {
render() {
return (
<Composition source="RefComponents">
{/* ViewRefs are useful to target a specific child component */}
<ViewRef name="View">
<TextRef name="Text" text="Hello"/>
</ViewRef>
{/* Will match the same TextRef above */}
<TextRef name="Info" text="No Need to select the parent ViewRef if the name is non-ambiguous"/>
</Composition>
);
}
}
name
After Effects layer name
Type | Required |
---|---|
String | Yes |
text
Text to display within this TextRef component.
Type | Required |
---|---|
string | No |
style
Type | Required |
---|---|
style | No |
fontFamily
: string
You can also use the font registry to specify the font family.
lineHeight
: numbertextAlign
: enum(‘auto’, ‘left’, ‘right’, ‘center’, ‘justify’)
You can also use the font registry to specify the font family.
textDecorationLine
: enum(‘none’, ‘underline’, ‘line-through’, ‘underline line-through’)
The line-through
text effect is not supported.
The value line-through
outputs same as none
; underline line-through
outputs same as underline
.
fontSize
: number
When fontSize is unset, the font size set in After Effects is applied. When fontSize is set to a value less than or equal to zero, the default size of 14 is used.
ellipsizeMode
Similar to ellipsizeMode prop of Facebook React Native Text component.
The values head
, middle
, and tail
ellipsize to tail
.
numberOfLines
Similar to numberOfLines prop of Facebook React Native Text component.
visible
Determines whether the component should be visible or not.
Default is true
.
Note the following:
Type | Required |
---|---|
bool | No |
onCompositionDidLoad
Invoked when the parent composition is loaded successfully and the Ref component gets attached to it.
testID
Similar to testID prop of Facebook React Native Text component.
tracking
Controls the tracking value. A positive tracking value increases the amount of space between letters, while negative value decreases the amount of space. The prop’s unit is iir
Type | Required |
---|---|
number | No |
kerning
Controls the kerning value. A positive kerning value increases the amount of space between letters, while a negative value decreases the amount of space.
Type | Required |
---|---|
number | No |
The tracking prop affects the space after a character, while the kerning prop affects the space before a character.
adjustsFontSizeToFit
Similar to adjustsFontSizeToFit prop of Facebook React Native Text component.
There are rare cases - which depend on the font itself and the size used - where text will append an ellipsis on the Roku client, but not on the server:
minimumFontScale
Similar to minimumFontScale prop of Facebook React Native Text component.
There are rare cases - which depend on the font itself and the size used - where text will append an ellipsis on the Roku client, but not on the server:
accessible
When true
, this property indicates that the view is an accessibility element.
The default is false.
Type | Required |
---|---|
bool | No |
Similar to React Native’s accessible
property.
accessibilityHint
A string that is read to help users understand what will happen when they perform an action on an accessibility element.
Type | Required |
---|---|
string | No |
This prop is similar to React Native’s accessibilityHint
property.
accessibilityLabel
The screen reader reads this string when a user selects the associated element. Setting a value for this prop allows users to know what element they’ve selected.
Type | Required |
---|---|
string | No |
Similar to React Native’s accessibilityLabel
property.
isTruncated
Returns whether the text was truncated because it didn’t fit into the given space.
<TextRef ref={descriptionRef} />
...
descriptionRef.current.isTruncated((truncated) => {
console.log("Was the text truncated? " + truncated);
});