Markdown

import Markdown from 'frui/fields/Markdown';
Copy

Props

Markdown accepts all props of a standard HTML Textare element. See Moz for standard textarea attributes.

NameTypeRequiredNotes
classNamestringNoStandard HTML class names
defaultValuestringNoDefault value (Uncontrolled)
errorstring|booleanNoAny error message
namestringNoUsed for react server components.
onChangeFunctionNoEvent handler when value has changed
onUpdateFunctionNoUpdate event handler
passRefLegacyRefNoPasses ref to html textarea
rowsnumberNoNumber of visible rows
styleCSS ObjectNoStandard CSS object
valuestringNoDefault value (Controlled)

Basics

Markdown wraps the HTML standard `<textarea />` element. Therefore, you can use any textarea attributes as props.

<Markdown name="name" placeholder="Enter name.." defaultValue="# Hello World" />
Copy

Events

onUpdate is like onChange except the value is passed instead of the change event.

<Markdown onUpdate={value => alert(value)} value="# Hello World" />
Copy

On Change

The onChange event is triggered when the value has changed. The following arguments are passed to the event handler:

NameTypeSample
eventEvent Objectsee: Change Event

On Update

The onUpdate event is triggered when the value has been updated. The following arguments are passed to the event handler:

NameTypeSample
valuestring`foobar`

Errors

You can pass the error prop to highlight the markdown field red.

<Markdown error onUpdate={value => alert(value)} value="# Not a hotdog." />
Copy