Label
type: 18
Modals
Preview modal.json
The Label wraps one input component in a modal and adds a title and a description. It’s the recommended way to build modals.
Sign up
Username*
This is how others will see you in the tournament.
e.g. SuperGamer
Your team*
Pick your team's role
{ "type": 9, "data": { "custom_id": "signup", "title": "Sign up", "components": [ { "type": 18, "label": "Username", "description": "This is how others will see you in the tournament.", "component": { "type": 4, "custom_id": "username", "style": 1, "placeholder": "e.g. SuperGamer", "max_length": 32 } }, { "type": 18, "label": "Your team", "component": { "type": 6, "custom_id": "team", "placeholder": "Pick your team's role" } } ] }}Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
type |
integer | required Always 18. |
id |
integer | optional Unique identifier. |
label |
string | required Title. Max 45 characters. |
description |
string | optional Help text. Max 100 characters. May be shown above or below the component. |
component |
component | required The input component (see below). |
What can go inside?
Section titled “What can go inside?”- Text Input
- String Select, User, Role, Mentionable and Channel Select
- File Upload
- Radio Group, Checkbox Group and Checkbox
Respond to the interaction with the JSON above (response type 9).
await interaction.showModal({ custom_id: 'signup', title: 'Sign up', components: [ { type: 18, label: 'Username', description: 'This is how others will see you in the tournament.', component: { type: 4, custom_id: 'username', style: 1, placeholder: 'e.g. SuperGamer', max_length: 32 }, }, { type: 18, label: 'Your team', component: { type: 6, custom_id: 'team', placeholder: "Pick your team's role" }, }, ],});class SignUp(discord.ui.Modal, title="Sign up"): username = discord.ui.Label( text="Username", description="This is how others will see you in the tournament.", component=discord.ui.TextInput(placeholder="e.g. SuperGamer", max_length=32), ) team = discord.ui.Label( text="Your team", component=discord.ui.RoleSelect(placeholder="Pick your team's role"), )
async def on_submit(self, interaction: discord.Interaction): role = self.team.component.values[0] await interaction.response.send_message( f"Welcome {self.username.component.value}! Team: {role.mention}", ephemeral=True )discordgo.Label{ Label: "Username", Description: "This is how others will see you in the tournament.", Component: discordgo.TextInput{ CustomID: "username", Style: discordgo.TextInputShort, Placeholder: "e.g. SuperGamer", MaxLength: 32, },}