Text
Baseβ
Italicβ
Sizes and weightsβ
Change the values to see the result.
Custom Elementβ
Coloredβ
Truncateβ
Word breakβ
Use the wordBreak property to break the words when is inside a container with limited width. It is useful when you don't control the size of displayed text (like URLs, subdomains, etc...).
Forwarded Propsβ
To wrap the Text in a styled() of the Styled Components, use the forwardedAs property to pass the desired styles. If not needed, use the as property, as per the custom element example.
import React from 'react';
import styled from 'styled-components';
import { Text } from '@resultadosdigitais/tangram-components';
const CustomText = styled(Text)`
margin-bottom: var(--size-spacing-04);
`;
const ForwardedProps = () => {
return (
<>
<CustomText as="div" textColor="--success-text" isItalic>
β Wrong way! The Text component doesn't receive the{' '}
<code>textColor</code> and <code>isItalic</code> props.
</CustomText>
<CustomText forwardedAs="div" textColor="--success-text" isItalic>
β
Correct way! The Text component receive the <code>textColor</code>{' '}
and <code>isItalic</code> props.
</CustomText>
</>
);
};
export default ForwardedProps;