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.
Name | Type | Required | Notes |
---|---|---|---|
className | string | No | Standard HTML class names |
defaultValue | string | No | Default value (Uncontrolled) |
error | string|boolean | No | Any error message |
name | string | No | Used for react server components. |
onChange | Function | No | Event handler when value has changed |
onUpdate | Function | No | Update event handler |
passRef | LegacyRef | No | Passes ref to html textarea |
rows | number | No | Number of visible rows |
style | CSS Object | No | Standard CSS object |
value | string | No | Default 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:
Name | Type | Sample |
---|---|---|
event | Event Object | see: Change Event |
On Update
The onUpdate
event is triggered when the value has been updated. The following arguments are passed to the event handler:
Name | Type | Sample |
---|---|---|
value | string | `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