Package Exports
- @silky/text
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@silky/text) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@silky/text
The <Text /> component is a React implementation of the <text> SVG element which defines a graphics element consisting of text. It's possible to apply a gradient, pattern, clipping path, mask, or filter to
If text is included within SVG not inside of a
Roadmap
- Vertical alignment
- Multiline text
- Dynamic scaling
Install
Yarn
yarn add @silky/textNPM
npm install --save @silky/textImport
ES5 Modules
import { Text } from '@silky/text';CommonJS
const Text = require('@silky/text');Browser
<script src="https://unpkg.com/@silky/text@:version/umd/silky-text.js"></script>Usage
In this example you can see how to pass translate and rotate values for the transform attribute.
const App = () => (
<svg>
<Text>foo</Text>
</svg>
);
render(<App />, document.getElementById('root'));Props
className
className?: string- Defaults:
'silky-text' - Description: any additional class name will be appended to the default one.
- Documentation: https://reactjs.org/docs/faq-styling.html
css
css?: Object- Defaults:
null - Description: accepts an Emotion CSS declaration using the
cssprop. - Documentation: https://emotion.sh/docs/css-prop
x
x?: number | string- Defaults:
null - Description: determines the x coordinate of the starting point of the text baseline.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/x
y
y?: number | string- Defaults:
null - Description: determines the y coordinate of the starting point of the text baseline.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/y
dy
dy?: number | string- Defaults:
null - Description: allows you to shift the text position vertically.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/dy
dx
dx?: number | string- Defaults:
null - Description: allows you to shift the text position horizontally.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/dx
dy
dy?: number | string- Defaults:
null - Description: allows you to shift the text position vertically.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/dy
lengthAdjust
lengthAdjust?: 'spacing' | 'spacingAndGlyphs'- Defaults:
null - Description: when an SVG
<text>or<tspan>element has a specific length, set using the textLength attribute, the lengthAdjust attribute controls how the text is stretched or compressed into that length. - Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/lengthAdjust
textLength
textLength?: number | string- Defaults:
null - Description: lets you specify the width of the space into which the text will draw.
- Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/textLength
transform
transform?: {
matrix?: [number]
rotate?: number | string
scale?: number | [number]
skew?: string | [string]
translate?: [number | string]
}- Defaults:
null - Description: will generate the correct
transformattribute value based on the properties passed in the object. - Documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform