본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

quasar-vue-components-list-and-list-items

원문 보기 위키 갱신

QList와 QItem은 함께 동작해 여러 줄의 항목(list item)을 하나의 연속된 요소로 세로로 표현하는 컴포넌트 그룹이에요. 연락처 목록, 재생 목록, 메뉴 같은 비슷한 데이터 타입을 정보의 행으로 보여줄 때 가장 잘 어울려요. 각 행을 Item이라고 불러요. QItem은 QList 밖에서도 사용할 수 있어요.

리스트(List)는 Item 또는 Item과 유사한 컴포넌트를 담을 수 있어요. 예를 들어 QExpansionItem이나 QSlideItem처럼요. 또 QSeparator를 사용해 필요할 때 섹션을 나눌 수도 있어요.

List Item에는 미리 만들어진 다음과 같은 하위 컴포넌트가 있어요:

  • QItemSection - 항목 섹션은 특정 콘텐츠에 대해 여러 가지 용도로 쓰일 수 있어요. avatar, thumbnail, side prop으로 제어해요. prop이 없으면 QItem의 메인 섹션(가능한 공간을 모두 차지하는)을 렌더링해요.
  • QItemLabel - 항목 라벨은 QItemSection 안의 미리 정의된 텍스트 콘텐츠 타입에 유용해요. 또는 QList 자체의 헤더 같은 콘텐츠에 사용해요.

출처: 문서

본문

QList API

Props

  • bordered (boolean, optional) Applies a default border to the component
  • dense (boolean, optional) Dense mode; occupies less space
  • separator (boolean, optional) Applies a separator between contained items
  • dark (boolean, optional), default null Notify the component that the background is a dark color
  • padding (boolean, optional) Applies a material design-like padding on top and bottom
  • tag (string, optional), default 'div' HTML tag to use Examples: 'div', 'ul', 'ol'
  • role (string, optional) (added v2.25) Overrides the default 'list' ARIA role; Contained QItems derive their own default role from it: with 'menu'/'menubar' the actionable items become 'menuitem's, while any other value stops the non-actionable items from claiming 'listitem' Examples: 'menu', 'listbox', 'none'

Slots

  • #default This is where the content goes; Suggestion: QItem, QExpansionItem, ...

QItem API

Props

Events

  • @click Emitted when the component is clicked Params:
    • evt (Event, optional) JS event object; If you are using route navigation ('to'/'replace' props) and you want to cancel navigation then call evt.preventDefault() synchronously in your event handler
    • go (Function, optional) Available ONLY if you are using route navigation ('to'/'replace' props); When you need to control the time at which the component should trigger the route navigation then call evt.preventDefault() synchronously and then call this function at your convenience; Useful if you have async work to be done before the actual route navigation or if you want to redirect somewhere else Function signature: (opts?: object) => Promise<any> Params:
      • opts (object, optional) Optional options Object shape:
        • to (string | object, optional) Equivalent to Vue Router 'to' property; Specify it explicitly otherwise it will be set with same value as component's 'to' prop Examples: '/home/dashboard', { name: 'my-route-name' }
        • replace (boolean, optional) Equivalent to Vue Router 'replace' property; Specify it explicitly otherwise it will be set with same value as component's 'replace' prop
        • returnRouterError (boolean, optional) Return the router error, if any; Otherwise the returned Promise will always fulfill Returns: Promise<any> Returns the router's navigation promise

Slots

  • #default This is where QItem's content goes

QItemSection API

Props

  • avatar (boolean, optional) Render an avatar item side (does not needs 'side' prop to be set)
  • thumbnail (boolean, optional) Render a thumbnail item side (does not needs 'side' prop to be set)
  • side (boolean, optional) Renders as a side of the item
  • top (boolean, optional) Align content to top (useful for multi-line items)
  • no-wrap (boolean, optional) Do not wrap text (useful for item's main content)

Slots

  • #default Section's actual content

QItemLabel API

Props

  • overline (boolean, optional) Renders an overline label
  • caption (boolean, optional) Renders a caption label
  • header (boolean, optional) Renders a header label
  • lines (number | string, optional) Apply ellipsis when there's not enough space to render on the specified number of lines;

Slots

  • #default The content of the label; Suggestion: text

사용법 (Usage)

기본 (Basic)

<template>
  <div style="max-width: 350px">
    <q-list bordered separator>
      <q-item clickable v-ripple>
        <q-item-section>Single line item</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label>Item with caption</q-item-label>
          <q-item-label caption>Caption</q-item-label>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label overline>OVERLINE</q-item-label>
          <q-item-label>Item with overline</q-item-label>
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

[!NOTE] @click 리스너가 있는 QItem은 기본적으로 클릭 가능해요(v2.29+): clickable prop 없이도 hover 효과, 키보드 활성화, click 이벤트를 얻어요. 리스너가 없을 때(예: v-close-popup 항목)나 불리언으로 동작을 토글해야 할 때만 clickable을 명시적으로 설정하세요. 명시적 clickable="false"는 리스너보다 우선해요.

예시 "Force dark mode":

<template>
  <div class="bg-grey-9 text-white">
    <q-list dark bordered separator style="max-width: 318px">
      <q-item clickable v-ripple>
        <q-item-section>Single line item</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label>Item with caption</q-item-label>
          <q-item-label caption>Caption</q-item-label>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label overline>OVERLINE</q-item-label>
          <q-item-label>Item with overline</q-item-label>
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

예시 "Dense":

<template>
  <div style="max-width: 350px">
    <q-list dense bordered padding class="rounded-borders">
      <q-item clickable v-ripple>
        <q-item-section> Item </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section> Item </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section> Item </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

QItemSection

예시 "Left avatar/thumbnail QItemSection":

<template>
  <div style="max-width: 350px">
    <q-list bordered>
      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-icon color="primary" name="bluetooth" />
        </q-item-section>

        <q-item-section>Icon as avatar</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar color="teal" text-color="white" icon="bluetooth" />
        </q-item-section>

        <q-item-section>Avatar-type icon</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar
            rounded
            color="purple"
            text-color="white"
            icon="bluetooth"
          />
        </q-item-section>

        <q-item-section>Rounded avatar-type icon</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar color="primary" text-color="white"> R </q-avatar>
        </q-item-section>

        <q-item-section>Letter avatar-type</q-item-section>
      </q-item>

      <q-separator />

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
        <q-item-section>Image avatar</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar square>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
        <q-item-section>Image square avatar</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar rounded>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
        <q-item-section>Image rounded avatar</q-item-section>
      </q-item>

      <q-separator />

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar rounded>
            <img
              alt="Mountains"
              src="https://cdn.quasar.dev/img/mountains.jpg"
            />
          </q-avatar>
        </q-item-section>
        <q-item-section>List item</q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section thumbnail>
          <img alt="Mountains" src="https://cdn.quasar.dev/img/mountains.jpg" />
        </q-item-section>
        <q-item-section>List item</q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

예시 "Right avatar/thumbnail QItemSection":

<template>
  <div style="max-width: 350px">
    <q-list bordered>
      <q-item clickable v-ripple>
        <q-item-section>Icon as avatar</q-item-section>
        <q-item-section avatar>
          <q-icon color="primary" name="bluetooth" />
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>Avatar-type icon</q-item-section>
        <q-item-section avatar>
          <q-avatar color="teal" text-color="white" icon="bluetooth" />
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>Rounded avatar-type icon</q-item-section>
        <q-item-section avatar>
          <q-avatar
            rounded
            color="purple"
            text-color="white"
            icon="bluetooth"
          />
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>Letter avatar-type</q-item-section>
        <q-item-section avatar>
          <q-avatar color="primary" text-color="white"> R </q-avatar>
        </q-item-section>
      </q-item>

      <q-separator />

      <q-item clickable v-ripple>
        <q-item-section>Image avatar</q-item-section>
        <q-item-section avatar>
          <q-avatar>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>Image square avatar</q-item-section>
        <q-item-section avatar>
          <q-avatar square>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>Image rounded avatar</q-item-section>
        <q-item-section avatar>
          <q-avatar rounded>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>
      </q-item>

      <q-separator />

      <q-item clickable v-ripple>
        <q-item-section>List item</q-item-section>
        <q-item-section avatar>
          <q-avatar rounded>
            <img
              alt="Mountains"
              src="https://cdn.quasar.dev/img/mountains.jpg"
            />
          </q-avatar>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>List item</q-item-section>
        <q-item-section thumbnail>
          <img alt="Mountains" src="https://cdn.quasar.dev/img/mountains.jpg" />
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

[!TIP] 여러 줄 항목이 있을 때 QItemSection side/avatar에 top 속성을 쓰면 섹션을 기본 중앙 정렬 대신 위쪽으로 정렬할 수 있어요.

예시 "Side QItemSection":

<template>
  <div style="max-width: 350px">
    <q-list>
      <q-item>
        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption lines="2"
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>5 min ago</q-item-label>
          <q-icon name="star" color="yellow" />
        </q-item-section>
      </q-item>

      <q-separator spaced inset />

      <q-item>
        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>Voted!</q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced inset />

      <q-item>
        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-badge color="teal" label="10k" />
        </q-item-section>
      </q-item>

      <q-separator spaced inset />

      <q-item>
        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>2 min ago</q-item-label>
          <div class="text-orange">
            <q-icon name="star" />
            <q-icon name="star" />
            <q-icon name="star" />
          </div>
        </q-item-section>
      </q-item>

      <q-separator spaced inset />

      <q-item>
        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>meta</q-item-label>
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

활성 상태 (Active state)

예시 "Active prop":

<template>
  <div class="q-gutter-md" style="max-width: 350px">
    <q-toggle v-model="active" label="Active" />

    <q-list bordered separator>
      <q-item clickable v-ripple :active="active">
        <q-item-section avatar>
          <q-icon name="signal_wifi_off" />
        </q-item-section>
        <q-item-section>Active</q-item-section>
        <q-item-section side>Side</q-item-section>
      </q-item>

      <q-item clickable v-ripple :active="active" active-class="text-orange">
        <q-item-section avatar>
          <q-icon name="signal_wifi_off" />
        </q-item-section>
        <q-item-section>Active, Active class</q-item-section>
        <q-item-section side>Side</q-item-section>
      </q-item>

      <q-item
        clickable
        v-ripple
        :active="active"
        active-class="bg-teal-1 text-grey-8"
      >
        <q-item-section avatar>
          <q-icon name="signal_wifi_off" />
        </q-item-section>
        <q-item-section>Active, Active class</q-item-section>
        <q-item-section side>Side</q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const active = ref(true)
</script>

QItemLabel

[!WARNING] 라벨 오버플로우는 lines prop으로 처리할 수 있다는 것을 참고하세요. 몇 줄까지 늘어날 수 있는지 알려주는 거예요. 단, 이 기능은 Webkit 전용 CSS를 사용해서 IE/Edge에서는 동작하지 않아요.

예시 "ItemLabel":

<template>
  <div style="max-width: 350px">
    <q-list bordered padding>
      <q-item>
        <q-item-section>
          <q-item-label overline>OVERLINE</q-item-label>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>5 min ago</q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced />
      <q-item-label header>List Header</q-item-label>

      <q-item>
        <q-item-section avatar>
          <q-icon color="primary" name="bluetooth" />
        </q-item-section>
        <q-item-section>List item</q-item-section>
        <q-item-section side>
          <q-item-label caption>meta</q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced inset="item" />

      <q-item>
        <q-item-section top avatar>
          <q-avatar color="primary" text-color="white" icon="bluetooth" />
        </q-item-section>

        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption lines="2"
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>5 min ago</q-item-label>
          <q-icon name="star" color="yellow" />
        </q-item-section>
      </q-item>

      <q-separator spaced inset="item" />

      <q-item>
        <q-item-section top avatar>
          <q-avatar
            color="primary"
            text-color="white"
            square
            icon="bluetooth"
          />
        </q-item-section>

        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>meta</q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced inset="item" />

      <q-item>
        <q-item-section top avatar>
          <q-avatar>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-badge label="10k" />
        </q-item-section>
      </q-item>

      <q-separator spaced inset="item" />

      <q-item>
        <q-item-section top avatar>
          <q-avatar rounded>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/boy-avatar.png"
            />
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>meta</q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced />

      <q-item>
        <q-item-section top thumbnail class="q-ml-none">
          <img alt="Mountains" src="https://cdn.quasar.dev/img/mountains.jpg" />
        </q-item-section>

        <q-item-section>
          <q-item-label>Single line item</q-item-label>
          <q-item-label caption
            >Secondary line text. Lorem ipsum dolor sit amet, consectetur
            adipiscit elit.</q-item-label
          >
        </q-item-section>

        <q-item-section side top>
          <q-item-label caption>meta</q-item-label>
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

더 복잡한 예시 (More involved examples)

예시 "Contact list":

<template>
  <div style="max-width: 350px">
    <q-toolbar class="bg-primary text-white shadow-2">
      <q-toolbar-title>Contacts</q-toolbar-title>
    </q-toolbar>

    <q-list bordered>
      <q-item
        v-for="contact in contacts"
        :key="contact.id"
        class="q-my-sm"
        clickable
        v-ripple
      >
        <q-item-section avatar>
          <q-avatar color="primary" text-color="white">
            {{ contact.letter }}
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label>{{ contact.name }}</q-item-label>
          <q-item-label caption lines="1">{{ contact.email }}</q-item-label>
        </q-item-section>

        <q-item-section side>
          <q-icon name="chat_bubble" color="green" />
        </q-item-section>
      </q-item>

      <q-separator />
      <q-item-label header>Offline</q-item-label>

      <q-item
        v-for="contact in offline"
        :key="contact.id"
        class="q-mb-sm"
        clickable
        v-ripple
      >
        <q-item-section avatar>
          <q-avatar>
            <img
              :alt="`${contact.name} avatar`"
              :src="`https://cdn.quasar.dev/img/${contact.avatar}`"
            />
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label>{{ contact.name }}</q-item-label>
          <q-item-label caption lines="1">{{ contact.email }}</q-item-label>
        </q-item-section>

        <q-item-section side>
          <q-icon name="chat_bubble" color="grey" />
        </q-item-section>
      </q-item>
    </q-list>
  </div>
</template>

<script setup>
const contacts = [
  {
    id: 1,
    name: 'Ruddy Jedrzej',
    email: 'rjedrzej0@discuz.net',
    letter: 'R'
  },
  // ...
]

const offline = [
  {
    id: 5,
    name: 'Brunhilde Panswick',
    email: 'bpanswick4@csmonitor.com',
    avatar: 'avatar2.jpg'
  },
  {
    id: 6,
    name: 'Winfield Stapforth',
    email: 'wstapforth5@pcworld.com',
    avatar: 'avatar6.jpg'
  }
]
</script>

예시 "Settings":

<template>
  <div style="max-width: 350px">
    <q-list bordered padding>
      <q-item-label header>User Controls</q-item-label>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label>Content filtering</q-item-label>
          <q-item-label caption>
            Set the content filtering level to restrict apps that can be
            downloaded
          </q-item-label>
        </q-item-section>
      </q-item>

      <q-item clickable v-ripple>
        <q-item-section>
          <q-item-label>Password</q-item-label>
          <q-item-label caption>
            Require password for purchase or use password to restrict purchase
          </q-item-label>
        </q-item-section>
      </q-item>

      <q-separator spaced />
      <q-item-label header>General</q-item-label>

      <q-item tag="label" v-ripple>
        <q-item-section side top>
          <q-checkbox v-model="check1" />
        </q-item-section>

        <q-item-section>
          <q-item-label>Notifications</q-item-label>
          <q-item-label caption>
            Notify me about updates to apps or games that I downloaded
          </q-item-label>
        </q-item-section>
      </q-item>

      <!-- ... -->

      <q-separator spaced />
      <q-item-label header>Notifications</q-item-label>

      <q-item tag="label" v-ripple>
        <q-item-section>
          <q-item-label>Battery too low</q-item-label>
        </q-item-section>
        <q-item-section side>
          <q-toggle color="blue" v-model="notif1" val="battery" />
        </q-item-section>
      </q-item>

      <q-item tag="label" v-ripple>
        <q-item-section>
          <q-item-label>Friend request</q-item-label>
          <q-item-label caption>Allow notification</q-item-label>
        </q-item-section>
        <q-item-section side top>
          <q-toggle color="green" v-model="notif2" val="friend" />
        </q-item-section>
      </q-item>

      <!-- ... -->

      <q-separator spaced />
      <q-item-label header>Other settings</q-item-label>

      <q-item>
        <q-item-section side>
          <q-icon color="teal" name="volume_down" />
        </q-item-section>
        <q-item-section>
          <q-slider v-model="volume" :min="0" :max="10" label color="teal" />
        </q-item-section>
        <q-item-section side>
          <q-icon color="teal" name="volume_up" />
        </q-item-section>
      </q-item>

      <q-item>
        <q-item-section side>
          <q-icon color="deep-orange" name="brightness_medium" />
        </q-item-section>
        <q-item-section>
          <q-slider
            v-model="brightness"
            :min="0"
            :max="10"
            label
            color="deep-orange"
          />
        </q-item-section>
      </q-item>

      <!-- ... -->
    </q-list>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const check1 = ref(true)
const check2 = ref(false)
const check3 = ref(false)

const notif1 = ref(true)
const notif2 = ref(true)
const notif3 = ref(false)

const volume = ref(6)
const brightness = ref(3)
const mic = ref(8)
</script>

예시 "Emails":

<template>
  <div class="q-gutter-md">
    <q-list bordered class="rounded-borders" style="max-width: 350px">
      <q-item-label header>Friends</q-item-label>

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/avatar2.jpg"
            />
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label lines="1">Brunch this weekend?</q-item-label>
          <q-item-label caption lines="2">
            <span class="text-weight-bold">Janet</span>
            -- I'll be in your neighborhood doing errands this weekend. Do you
            want to grab brunch?
          </q-item-label>
        </q-item-section>

        <q-item-section side top> 1 min ago </q-item-section>
      </q-item>

      <q-separator inset="item" />

      <q-item clickable v-ripple>
        <q-item-section avatar>
          <q-avatar>
            <img
              alt="User avatar"
              src="https://cdn.quasar.dev/img/avatar4.jpg"
            />
          </q-avatar>
        </q-item-section>

        <q-item-section>
          <q-item-label lines="1">Linear Project</q-item-label>
          <q-item-label caption lines="2">
            <span class="text-weight-bold">John</span>
            -- Can we schedule a call for tomorrow?
          </q-item-label>
        </q-item-section>

        <q-item-section side top> 1 min ago </q-item-section>
      </q-item>
    </q-list>

    <q-list bordered class="rounded-borders" style="max-width: 600px">
      <q-item-label header>Google Inbox style</q-item-label>

      <q-item>
        <q-item-section avatar top>
          <q-icon name="account_tree" color="black" size="34px" />
        </q-item-section>

        <q-item-section top class="col-2 gt-sm">
          <q-item-label class="q-mt-sm">GitHub</q-item-label>
        </q-item-section>

        <q-item-section top>
          <q-item-label lines="1">
            <span class="text-weight-medium">[quasarframework/quasar]</span>
            <span class="text-grey-8"> - GitHub repository</span>
          </q-item-label>
          <q-item-label caption lines="1">
            @rstoenescu in #3: > Generic type parameter for props
          </q-item-label>
          <q-item-label
            lines="1"
            class="q-mt-xs text-body2 text-weight-bold text-primary text-uppercase"
          >
            <span class="cursor-pointer">Open in GitHub</span>
          </q-item-label>
        </q-item-section>

        <q-item-section top side>
          <div class="text-grey-8 q-gutter-xs">
            <q-btn class="gt-xs" size="12px" flat dense round icon="delete" />
            <q-btn class="gt-xs" size="12px" flat dense round icon="done" />
            <q-btn size="12px" flat dense round icon="more_vert" />
          </div>
        </q-item-section>
      </q-item>

      <!-- ... -->
    </q-list>
  </div>
</template>

예시 "Folder listing":

<template>
  <div class="q-gutter-md">
    <q-list bordered padding class="rounded-borders" style="max-width: 350px">
      <q-item-label header>Folders</q-item-label>

      <q-item clickable v-ripple>
        <q-item-section avatar top>
          <q-avatar icon="folder" color="primary" text-color="white" />
        </q-item-section>

        <q-item-section>
          <q-item-label lines="1">Photos</q-item-label>
          <q-item-label caption>February 22nd, 2019</q-item-label>
        </q-item-section>

        <q-item-section side>
          <q-icon name="info" color="green" />
        </q-item-section>
      </q-item>

      <!-- ... -->

      <q-separator spaced />
      <q-item-label header>Files</q-item-label>

      <q-item clickable v-ripple>
        <q-item-section avatar top>
          <q-avatar icon="assignment" color="grey" text-color="white" />
        </q-item-section>

        <q-item-section>
          <q-item-label lines="1">Expenses spreadsheet</q-item-label>
          <q-item-label caption>March 2nd, 2019</q-item-label>
        </q-item-section>

        <q-item-section side>
          <q-icon name="info" />
        </q-item-section>
      </q-item>

      <!-- ... -->
    </q-list>
  </div>
</template>

아래 예시에서는 데모 목적으로 QItem의 라우터 prop(to, exact) 대신 active prop을 사용했어요. UMD에는 Vue Router가 없어서 Codepen/jsFiddle에서 그걸로 실습할 수 없거든요.

예시 "Menu":

<template>
  <div style="max-width: 250px">
    <q-list bordered padding class="rounded-borders text-primary">
      <q-item
        v-ripple
        :active="link === 'inbox'"
        @click="link = 'inbox'"
        active-class="my-menu-link"
      >
        <q-item-section avatar>
          <q-icon name="inbox" />
        </q-item-section>

        <q-item-section>Inbox</q-item-section>
      </q-item>

      <!-- ... -->
    </q-list>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const link = ref('inbox')
</script>

<style lang="sass">
.my-menu-link
  color: white
  background: #F2C037
</style>

[!TIP] 더 복잡한 메뉴라면 QExpansionItem도 함께 고려해 보세요.

Vue Router에 연결 (Connecting to Vue Router)

QItem을 <router-link> 속성을 바인딩해서 Vue Router와 함께 쓸 수 있어요. 이렇게 하면 현재 앱 라우트를 들을 수 있고, 클릭/탭했을 때 라우트를 트리거할 수도 있어요.

<q-item to="/inbox" exact>
  <q-item-section avatar>
    <q-icon name="inbox" />
  </q-item-section>

  <q-item-section> Inbox </q-item-section>
</q-item>

아래에서 보듯 내비게이션을 지연, 취소하거나 리다이렉트할 수도 있어요. 아래에서 사용한 @click 이벤트에 대한 더 자세한 설명은 페이지 상단의 QItem API 카드를 참조하세요.

예시 "지연·취소·리다이렉트된 내비게이션 링크":

<template>
  <div class="q-gutter-sm">
    <q-item to="/" @click="onDelayedClick" dense>
      <q-item-section>Delayed navigation</q-item-section>
    </q-item>

    <q-item to="/" @click="onCancelledClick" dense>
      <q-item-section>Cancelled navigation</q-item-section>
    </q-item>

    <q-item to="/" @click="onRedirectedClick" dense>
      <q-item-section>Redirected navigation</q-item-section>
    </q-item>
  </div>
</template>

<script setup>
function onDelayedClick(e, go) {
  e.preventDefault() // mandatory; we choose when we navigate

  console.log('triggering navigation in 2s')
  setTimeout(() => {
    console.log('navigating as promised 2s ago')
    go()
  }, 2000)
}

function onCancelledClick(e, go) {
  e.preventDefault() // mandatory; we choose when we navigate
  // then we never call go()
}

function onRedirectedClick(e, go) {
  e.preventDefault() // mandatory; we choose when we navigate

  // call this at your convenience
  go({
    to: '/start/pick-quasar-flavour' // we pick another route
    // replace: boolean; default is what the tab is configured with
    // returnRouterError: boolean
  })
    .then(_vueRouterResult => {
      /* ... */
    })
    .catch(_vueRouterError => {
      /* ...will not reach here unless returnRouterError === true */
    })
}
</script>

접근성 (Accessibility) (v2.25+)

QList는 기본적으로 WAI-ARIA list 역할을 노출해요(tag prop으로 ul/ol로 렌더링될 때는 암시적으로) 그리고 role prop이 그것을 덮어써요. 각 QItem은 그것을 감싼 QList에서 기본 역할을 파생해요:

QItem inside default QList inside QList with role="menu"/"menubar" outside QList / other QList role
with clickable, a @click listener or a link button / native link menuitem button / native link
non-interactive listitem none none

이렇게 하면 산출된 마크업이 유효해져요: ARIA의 list는 오직 listitem 자식만 가질 수 있고(그 자식들은 list 부모를 요구하므로 단독 QItem은 역할을 주장하지 않아요), menu/menubar는 오직 menuitem 타입 항목만 가질 수 있어요 — QMenu의 접근성 섹션의 "Basic" 예시처럼 QList에 역할을 한 번만 선언하면 충분해요. QItem의 role prop은 단일 항목에 대해 파생된 역할을 덮어써요(예: 토글 항목의 menuitemcheckbox/menuitemradio — 그러면 aria-checked 관리는 여러분 몫이에요).

[!WARNING] 대화형 아이템으로만 이루어진 리스트에는 list 역할을 주장할 자격이 없어요 — 그런 컨테이너는 listitem 자식을 갖지 않으니까요. 실제로 무엇인지 선언하세요: 명령 목록으로 팝업되면 role="menu", 아니면 리스트 의미론 없이 항목(버튼/링크로 알림)을 유지하려면 role="none".

더 알아보기 (Learn more)