Chapter 888: fitText()
Core Idea
_Part of the @remotion/layout-utils package. Available from v4.
Key Concepts
- API
- text
- withinWidth
- fontFamily
- fontWeight?
- letterSpacing?
- fontVariantNumeric?
- textTransform<AvailableFrom v="4.0.140"/>
Code Examples
const text = "Hello World";
const width = 100;
const fontFamily = "Arial";
const fontWeight = "bold";
const { fontSize } = fitText({
text,
withinWidth: width,
fontFamily: fontFamily,
fontWeight: fontWeight,
textTransform: "uppercase",
});
// Example markup:
<div
style={{
fontSize,
width,
fontFamily,
fontWeight,
textTransform: "uppercase",
}}
>
{text}
</div>;
- What it demonstrates: Usage pattern for fitText() from the official docs.
Key Takeaways
- Understand api when working with fitText().
- Understand text when working with fitText().
- Understand withinwidth when working with fitText().
- Understand fontfamily when working with fitText().
- Understand fontweight? when working with fitText().
Connects To
- Best Practices: related page in the Layout Utils (@remotion/layout-utils) section.
- Debug: related page in the Layout Utils (@remotion/layout-utils) section.
- Fill Text box: related page in the Layout Utils (@remotion/layout-utils) section.