# Structured text
`` is a Vue component that you can use to render the value contained inside a DatoCMS [Structured Text field type](https://www.datocms.com/docs/structured-text/dast).
## Table of Contents
- [Setup](#setup)
- [Basic usage](#basic-usage)
- [Custom renderers](#custom-renderers)
- [Override default rendering of nodes](#override-default-rendering-of-nodes)
- [Props](#props)
## Setup
You can register the component globally so it's available in all your apps:
```js
import Vue from 'vue';
import { DatocmsStructuredTextPlugin } from 'vue-datocms';
Vue.use(DatocmsStructuredTextPlugin);
```
Or use it locally in any of your components:
```js
import { StructuredText } from 'vue-datocms';
export default {
components: {
'datocms-structured-text': StructuredText,
},
};
```
## Basic usage
```vue
{{ data.blogPost.title }}
```
## Custom renderers
You can also pass custom renderers for special nodes (inline records, record links and blocks) as an optional parameter like so:
```vue
{{ data.blogPost.title }}
```
## Override default rendering of nodes
This component automatically renders all nodes except for `inlineItem`, `itemLink`, `block` and `inlineBlock` using a set of default rules, but you might want to customize those. For example:
- For `heading` nodes, you might want to add an anchor;
- For `code` nodes, you might want to use a custom sytax highlighting component;
In this case, you can easily override default rendering rules with the `customNodeRules` and `customMarkRules` props.
```vue
```
Note: if you override the rules for `inlineItem`, `itemLink`, `block` or `inlineBlock` nodes, then the `renderInlineRecord`, `renderLinkToRecord`, `renderBlock`, `renderInlineBlock` props won't be considered!
## Props
| prop | type | required | description | default |
| ------------------ | ---------------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| data | `StructuredTextGraphQlResponse \| DastNode` | :white_check_mark: | The actual [field value](https://www.datocms.com/docs/structured-text/dast) you get from DatoCMS | |
| renderInlineRecord | `({ record }) => VNode \| null` | Only required if document contains `inlineItem` nodes | Convert an `inlineItem` DAST node into a VNode | `[]` |
| renderLinkToRecord | `({ record, children, transformedMeta }) => VNode \| null` | Only required if document contains `itemLink` nodes | Convert an `itemLink` DAST node into a VNode | `null` |
| renderBlock | `({ record }) => VNode \| null` | Only required if document contains `block` nodes | Convert a `block` DAST node into a VNode | `null` |
| renderInlineBlock | `({ record }) => VNode \| null` | Only required if document contains `inlineBlock` nodes | Convert an `inlineBlock` DAST node into a VNode | `null` |
| metaTransformer | `({ node, meta }) => Object \| null` | :x: | Transform `link` and `itemLink` meta property into HTML props | [See function](https://github.com/datocms/structured-text/blob/main/packages/generic-html-renderer/src/index.ts#L61) |
| customNodeRules | `Array` | :x: | Customize how nodes are converted in JSX (use `renderNodeRule()` to generate) | `null` |
| customMarkRules | `Array` | :x: | Customize how marks are converted in JSX (use `renderMarkRule()` to generate) | `null` |
| renderText | `(text: string, key: string) => VNode \| string \| null` | :x: | Convert a simple string text into a VNode | `(text) => text` |