Skip to content

JSX Elements

Here is a list of every JSX element discord-jsx-renderer supports.


Root Elements

message

proptypedescription
ephemeral?booleanMake reply ephemeral
v2?booleanUse Components v2

Children can be;

  • If not v2: text content
  • If v2:
jsx
<message>
    This is a normal message component! {"\n"}
    You can use {"JSX"} inside.
</message>

<message v2>
    <text>
        This one uses ComponentsV2!
    </text>
</message>

Layout Elements

container

proptypedescription
color?ColorResolvableContainer accent color
spoiler?boolean

Children can be (up to 10 max):

row

Action Row component

Children can be:

section

tsx
<section>
    <accessory>
        {/* <thumbnail> or <button> */}
    </accessory>
    {/* components... */}
</section>

Children must have a single <accessory> element which must have <thumbnail> or <button>

Children can also have:

tsx
// Example
<section>
    <text>
        Check out latest news
    </text>

    <accessory>
        <button
            onClick={showNews}
        >
            News
        </button>
    </accessory>
</section>

Interactive Elements

button

Children will become button label

proptypedescription
onClick?(ButtonInteraction) => voidclick event
style?"primary" | "secondary" | "success" | "danger"style if normal button
disabled?booleandisabled state
url?stringif specified, will become a link button
skuId?stringif specified, will become a premium button
customId?stringexperimental

select

Children are not allowed

proptypedescription
type"string" | "user" | "role" | "mentionable" | "channel"Select component type
onSelect?(Snowflake[], AnySelectMenuInteraction) => voidinteraction type is derived from type prop
min?numberminimum amount
max?numbermaximum amount
disabled?booleandisabled state
placeholder?string
options?Omit<APISelectMenuOption, "default">[]only on type="select"
defaultValues?Snowflake[]only on type="user" or "role" or "channel"
defaultValues?{ id: Snowflake, type: "user" | "role" }[]only on type="mentionable"
channelTypes?ChannelType[]only on type="channel"
customId?stringexperimental

Content Elements

text

Children will become text content.

separator

proptypedescription
divider?boolean
spacing?"sm" | "lg"

thumbnail

proptypedescription
description?stringalt text
spoiler?boolean
media?stringurl
proptypedescription
items?APIMediaGalleryItem[]gallery items

file

proptypedescription
file?stringurl as attachment://...
spoiler?boolean