Skip to content

Text Item

Renders a text block on the canvas with full typography control, including fonts, alignment, decorations, and effects.

Note: height is not required for text items. The height adjusts automatically based on the font size, line height, and width. You only need to set width.

Creating a Text Item

tsx
const { addItem } = useStudio()

addItem('Text', {
  x: 100,
  y: 100,
  width: 500,
  itemProps: {
    text: 'Hello, World!',
    fontSize: 48,
    fontFamily: 'Inter',
    lineHeight: 1.2,
    color: '#ffffff',
  },
})

Properties

All properties below are passed inside itemProps.

Content

PropertyTypeDescription
textstringThe text content. Required.

Font & Size

PropertyTypeDescription
fontSizenumberFont size in pixels. Required.
fontFamilystringFont family name (e.g. 'Inter', 'Georgia'). Required.
lineHeightnumberLine height multiplier (e.g. 1.2). Required.
letterSpacingnumberLetter spacing in pixels.
boldbooleanBold text.
italicbooleanItalic text.
underlinebooleanUnderline decoration.
strikethroughbooleanStrikethrough decoration.
uppercasebooleanUppercase transform.

Alignment

PropertyTypeDescription
align'left' | 'center' | 'right'Horizontal text alignment.

Color & Background

PropertyTypeDescription
colorstringText color (hex).
backgroundColorstringBackground color behind the text.
backgroundType'full' | 'line'Whether the background fills the full box or each line.
backgroundRadiusnumberCorner radius of the background.
paddingnumberPadding around the background.
strokestringStroke color around the text.
strokeWidthnumberStroke width in pixels.
blurnumberBlur amount applied to the text.

Shadow

PropertyTypeDescription
shadowEnabledbooleanEnable or disable the shadow.
shadowColorstringShadow color.
shadowBlurnumberShadow blur radius.
shadowOffsetXnumberShadow horizontal offset.
shadowOffsetYnumberShadow vertical offset.

Full Example

tsx
addItem('Text', {
  x: 80,
  y: 80,
  width: 600,
  itemProps: {
    text: 'Asset Studio',
    fontSize: 64,
    fontFamily: 'Inter',
    lineHeight: 1.2,
    bold: true,
    color: '#ffffff',
    align: 'center',
    letterSpacing: 2,
    shadowEnabled: true,
    shadowColor: '#000000',
    shadowBlur: 10,
    shadowOffsetX: 2,
    shadowOffsetY: 4,
  },
})

Released under a proprietary license.