@silky/text

Silky Text

Usage no npm install needed!

<script type="module">
  import silkyText from 'https://cdn.skypack.dev/@silky/text';
</script>

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 , just like any other SVG graphics element.

If text is included within SVG not inside of a element, it is not rendered. This is different from being hidden by default, as setting the display property will not show the text.

Roadmap

  • Vertical alignment
  • Multiline text
  • Dynamic scaling

Install

Yarn

yarn add @silky/text

NPM

npm install --save @silky/text

Import

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

css

  css?: Object

x

  x?: number | string

y

  y?: number | string

dy

  dy?: number | string

dx

  dx?: number | string

dy

  dy?: number | string

lengthAdjust

  lengthAdjust?: 'spacing' | 'spacingAndGlyphs'

textLength

  textLength?: number | string

transform

  transform?: {
    matrix?: [number]
    rotate?: number | string
    scale?: number | [number]
    skew?: string | [string]
    translate?: [number | string]
  }