Skip to content

Prompts Component ๐ŸŽ โ€‹

Introduction โ€‹

Prompts is used to display a set of predefined questions or suggestions related to the current context.

Code Examples โ€‹

Basic Usage โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› Prompts Component Title
๐Ÿ› Prompts Component Title
๐Ÿ› Prompts Component Title

Quickly create a set of prompts list. By default, overflow will not wrap and scrollbars are hidden.

Disabled State โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› I am disabled
๐Ÿ› Individual disable control is more accurate
๐Ÿ› Prompts Component Title

Quickly disable the prompts component through the disabled attribute, click events will be invalid. Note that this only takes effect when controlling individual prompt items.

Vertical Layout โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› I am disabled
๐Ÿ› Individual disable control is more accurate
๐Ÿ› Prompts Component Title

Use the vertical attribute to control the display direction of Prompts. Note that this acts on the entire Prompts component, not on individual PromptsItem.

Wrapping โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› I am disabled
๐Ÿ› Individual disable control is more accurate
๐Ÿ› Prompts Component Title

Use the wrap attribute to control whether Prompts can wrap when exceeding the area length.

Responsive Width โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› I am disabled
๐Ÿ› Individual disable control is more accurate
๐Ÿ› Prompts Component Title

Combined with wrap and styles to display with fixed width. Note that this only takes effect when used together on PromptsItem. Individual use allows for more customization.

Customized Styles โ€‹

๐Ÿต Prompts Component Title
๐Ÿ› Prompts Component Title

Description informationDescription informationDescription information

๐Ÿ› I am disabled
๐Ÿ› Individual disable control is more accurate
๐Ÿ› Prompts Component Title

Customize the styles of prompts through the style attribute.

Customize the styles of individual prompts through itemStyle, itemHoverStyle, and itemActiveStyle attributes.

Nested Combination โ€‹

๐Ÿ› Prompts Component Title

Quickly create a set of prompts list. By default, overflow will not wrap and scrollbars are hidden.

Attributes โ€‹

AttributeTypeRequiredDefaultDescription
titlestringNo''Main title text content of the prompts set
itemsPromptsItemsProps[]No[]Array of prompt items, each element contains label, icon, description and other information (see structure details below)
wrapbooleanNofalseWhether to allow prompt items to wrap automatically (only effective in horizontal layout)
verticalbooleanNofalseWhether to arrange prompt items vertically (layout direction is column in vertical mode)
styleCSSPropertiesNo{}Custom styles for component container (directly applied to the outermost div.el-prompts)

PromptsItemsProps Structure Details (single prompt item attributes):

typescript
interface PromptsItemsProps {
  key: string | number; // Unique identifier (for state association)
  label?: string; // Prompt item label text
  icon?: ComponentVNode; // Prompt item icon (Vue component form)
  description?: string; // Prompt item description text
  disabled?: boolean; // Whether disabled (no interaction response when disabled)
  itemStyle?: CSSProperties; // Custom base styles for prompt item
  itemHoverStyle?: CSSProperties; // Custom styles for prompt item hover state
  itemActiveStyle?: CSSProperties; // Custom styles for prompt item active state
  children?: PromptsItemsProps[]; // Child prompt items array (for nested display)
}

Events โ€‹

Event NameParametersTypeDescription
@itemClick(item: PromptsItemsProps)FunctionEvent triggered when a prompt item is clicked.

Slots โ€‹

Slot NameParametersTypeDescription
#title-SlotCustom prompt set title content (if title attribute is also set, slot content will override attribute text)
#icon{ item: PromptsItemsProps }SlotCustom icon content for prompt item (receives current prompt item item parameter, can override item.icon)
#label{ item: PromptsItemsProps }SlotCustom label content for prompt item (receives current prompt item item parameter, can override item.label)
#description{ item: PromptsItemsProps }SlotCustom description content for prompt item (receives current prompt item item parameter, can override item.description)

Features โ€‹

  1. Multi-dimensional Content Display: Supports configuring basic information such as labels, icons, and descriptions through the items attribute, while providing label/icon/description slots for highly customizable content.
  2. Flexible Layout Control: Switch between vertical/horizontal arrangement modes through the vertical attribute, control automatic wrapping capability in horizontal arrangement through the wrap attribute, adapting to different scene layout requirements.
  3. Interactive State Feedback: Built-in hover (background color lightens) and active (background color darkens) state styles, supports custom state styles through itemHoverStyle/itemActiveStyle, enhancing interactive experience.
  4. Disabled State Support: Individual prompt items can be disabled through the item.disabled attribute. In disabled state, no response to click events and background color turns gray, clearly indicating non-operable state.
  5. Nested Hierarchy Display: Supports configuring child prompt items through item.children, component automatically recursively renders nested structure, meeting multi-level classification or related prompt display requirements.
  6. Fine-grained Style Customization: Supports controlling overall component styles through the style attribute, controlling individual prompt item base styles through itemStyle, supports separate state style configuration (itemHoverStyle/itemActiveStyle).