LogoLogo
  • What is UDML?
  • Document structure
    • <components>
    • <imports>
    • <instructions>
    • <meta>
    • <styles>
    • <tokens>
    • <mappings>
    • <screens>
  • Directives
    • ai-hint
    • <data> Directive Specification
    • <interaction> Directive
    • <layer> Directive
    • <repeat> Directive
    • <responsive>
    • selection
    • <tracking> Directive
  • Components
    • Layout
      • <accordion> Component
      • <box> Component
      • <column> Component
      • <divider>
      • <grid> Component
      • <row> Component
    • Navigation
      • <breadcrumbs> Component
      • <pagination> Component
      • <tab> Component
      • <tabs> Component
    • Text & Display
      • <avatar>
      • <heading>
      • <icon>
      • <image>
      • <label>
      • <text>
      • <video>
    • Controls & Input
      • <button>
      • <checkbox>
      • <input> Component
      • <radio>
      • <select>
      • <slider>
      • <stepper>
      • <switch>
      • <textarea>
    • Forms
      • <form> Component
      • <formField> Component
      • <formGroup> Component
    • Data Collections
      • <dataColumn> Component
      • <dataTable> Component
      • <list> Component
      • <timeline> Component
      • <treeView> Component
    • Data Visualization
      • <chart> Component
      • <summary> Component
    • Modals
      • <dialog> Component
      • <modal> Component
      • <popover> Component
      • <toast> Component
      • <tooltip> Component
  • Prompting Guides
    • Prompting AI Developer Tools with UDML
    • Working with UDML in an Existing Codebase
  • Contributing to UDML
Powered by GitBook
On this page
  • 🛠 Attributes
  • Child Item Attributes
  • 💡 Examples
  • 🧩 AI Interpretation Guidelines
Edit on GitHub
  1. Directives

selection

These attributes can be added to any container component to enable selection behavior.

🛠 Attributes

Attribute
Type
Required
Description

selectionMode

string

No

Selection behavior (single, multiple)

maxSelections

number

No

Maximum number of selectable items

allowDeselect

boolean

No

Allow deselecting selected items

selectedClass

string

No

CSS class to apply to selected items

onSelect

string

No

Handler for selection events

Child Item Attributes

These attributes can be applied to items within a selection-enabled container:

Attribute
Type
Required
Description

selectable

boolean

No

Whether the item can be selected

selected

boolean

No

Initial selected state

disabled

boolean

No

Prevent selection

💡 Examples

Photo Gallery Selection

<grid 
  columns="repeat(3, 1fr)" 
  gap="16px"
  selectionMode="multiple"
  maxSelections="3"
  selectedClass="selected"
  onSelect="handlePhotoSelect"
>
  <repeat source="photos">
    <box selectable="true">
      <image bind="url"/>
    </box>
  </repeat>
</grid>

List with Single Selection

<column 
  gap="8px"
  selectionMode="single"
  selectedClass="selected"
  onSelect="handleItemSelect"
>
  <repeat source="items">
    <box 
      selectable="true"
      padding="16px"
    >
      <text bind="name"/>
    </box>
  </repeat>
</column>

Nested Selection Groups

<column gap="24px">
  <text>Select up to 3 photos:</text>
  <grid 
    columns="repeat(3, 1fr)" 
    gap="16px"
    selectionMode="multiple"
    maxSelections="3"
  >
    <repeat source="photos">
      <box selectable="true">
        <image bind="url"/>
      </box>
    </repeat>
  </grid>
  
  <text>Select one category:</text>
  <column 
    gap="8px"
    selectionMode="single"
  >
    <repeat source="categories">
      <box selectable="true">
        <text bind="name"/>
      </box>
    </repeat>
  </column>
</column>

🧩 AI Interpretation Guidelines

  • Add appropriate selection state management

  • Generate selection event handlers

  • Apply selectedClass to selected items

  • Handle selection constraints (maxSelections)

  • Manage selection mode (single/multiple)

  • Support keyboard navigation and accessibility

  • Handle nested selection contexts


Previous<responsive>Next<tracking> Directive

Last updated 2 months ago