List Svelte Component

List views are versatile and powerful user interface compontents frequently found in iOS apps. A list view presents data in a scrollable list of multiple rows that may be divided into sections/groups.

List views have many purposes:

  • To let users navigate through hierarchically structured data
  • To present an indexed list of items
  • To display detail information and controls in visually distinct groupings
  • To present a selectable list of options

List Svelte component represents Framework7's List View component.

List Components

There are following components included:

  • List - main List View element
  • ListGroup - list group element

List Properties

PropTypeDefaultDescription
<List> properties
ulbooleantrueWraps children with <ul>. Recommended to disable used with nested <ListGroup>
insetbooleanfalseMakes list block inset
xsmallInsetbooleanMakes block inset when app width >= 480px
smallInsetbooleanMakes block inset when app width >= 568px
mediumInsetbooleanMakes block inset when app width >= 768px
largeInsetbooleanMakes block inset when app width >= 1024px
xlargeInsetbooleanMakes block inset when app width >= 1200px
mediaListbooleanfalseEnables Media List
linksListbooleanfalseEnables simplified Links List
simpleListbooleanfalseEnables simplified Simple List
sortablebooleanfalseEnables Sortable List
sortableOppositebooleanfalseRenders sortable handler on opposite side (on left in LTR)
sortableTapHoldbooleanfalseMakes list items sortable on item tap and hold (long press). In this case app will rely on custom taphold event. To make it work correctly, make sure you have also enabled touch.tapHold: true app parameter
sortableEnabledbooleanfalseEnables sorting on sortable list
sortableMoveElementsbooleanWhen passed it will overwrite same sortable.moveElements global app parameter.
accordionbooleanfalseEnables Accordion List
accordionOppositebooleanfalseRenders accordion chevron icon on opposite side (on left in LTR)
contactsListbooleanfalseEnables Contacts List by adding required addional classes for styling
formbooleanfalseEnables <form> tag on list block instead of <div>
formStoreDatabooleanfalseEnables form storage for the current form
inlineLabelsbooleanfalseEnables inline-styled labels for Form Inputs
noChevronbooleanfalseRemoves "chevron" icon on nested list item links
chevronCenterbooleanfalseSets "chevron" icon on nested media list items on center (vertically)
noHairlinesbooleanfalseRemoves outer hairlines
noHairlinesMdbooleanfalseRemoves outer hairlines for MD theme
noHairlinesIosbooleanfalseRemoves outer hairlines for iOS theme
noHairlinesBetweenbooleanfalseRemoves inner hairlines between items
noHairlinesBetweenMdbooleanfalseRemoves inner hairlines between items for MD theme
noHairlinesBetweenIosbooleanfalseRemoves inner hairlines between items for iOS theme
tabbooleanfalseAdds additional "tab" class when block should be used as a Tab
tabActivebooleanfalseAdds additional "tab-active" class when block used as a Tab and makes it active tab
virtualListbooleanfalseEnables Virtual List
virtualListParamsobjectObject with Virtual List Parameters
<ListGroup> properties
mediaListbooleanfalseEnables Media List for this group
sortablebooleanfalseEnables Sortable List for this group
sortableTapHoldbooleanfalseMakes list items sortable on item tap and hold (long press). In this case app will rely on custom taphold event. To make it work correctly, make sure you have also enabled touch.tapHold: true app parameter
simpleListbooleanfalseEnables simplified Simple List for this group

List Events

EventDescription
<List> events
tabShowEvent will be triggered when List Block-Tab becomes visible/active
tabHideEvent will be triggered when List Block-Tab becomes invisible/inactive
submitEvent will be triggered on list-form submit when list used as form (with enabled form prop)
<List> Sortable specific events
sortableEnableEvent will be triggered when sortable mode is enabled
sortableDisableEvent will be triggered when sortable mode is disabled
sortableSortEvent will be triggered after user release currently sorting element in new position. event.detail will contain object with from and to properties with start/new index numbers of sorted list item
<List> Virtual List specific events
virtualItemBeforeInsertEvent will be triggered before item will be added to virtual document fragment
virtualItemsBeforeInsertEvent will be triggered after current DOM list will be removed and before new document will be inserted
virtualItemsAfterInsertEvent will be triggered after new document fragment with items inserted
virtualBeforeClearEvent will be triggered before current DOM list will be removed and replaced with new document fragment

List Slots

List Svelte component (<List>) has additional slots for custom elements:

  • before-list - element will be inserted in the beginning of list view and right before <ul> main list
  • after-list - element will be inserted in the end of list view and right after <ul> main list
  • list - element will be inserted inside of <ul> main list element

Virtual List

For Virtual List usage and examples check the Virtual List Svelte Component documentation.

Sortable List

For Sortable List usage and examples check the Sortable Svelte Component documentation.

Accordion List

For Accordion List usage and examples check the Accordion Svelte Component documentation.

Examples

<Page>
  <Navbar title="List View"></Navbar>
  <BlockTitle>Simple List</BlockTitle>
  <List simpleList>
    <ListItem title="Item 1"></ListItem>
    <ListItem title="Item 2"></ListItem>
    <ListItem title="Item 3"></ListItem>
  </List>
  <BlockTitle>Simple Links List</BlockTitle>
  <List>
    <ListItem title="Link 1" link="#"></ListItem>
    <ListItem title="Link 2" link="#"></ListItem>
    <ListItem title="Link 3" link="#"></ListItem>
  </List>
  <BlockTitle>Data list, with icons</BlockTitle>
  <List>
    <ListItem title="Ivan Petrov" after="CEO">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem title="John Doe" badge="5">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem title="Jenna Smith">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
  </List>
  <BlockTitle>Links</BlockTitle>
  <List>
    <ListItem link="#" title="Ivan Petrov" after="CEO">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="John Doe" after="Cleaner">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Jenna Smith">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
  </List>
  <BlockTitle>Links, Header, Footer</BlockTitle>
  <List>
    <ListItem link="#" header="Name" title="John Doe" after="Edit">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" header="Phone" title="+7 90 111-22-3344" after="Edit">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" header="Email" title="john@doe" footer="Home" after="Edit">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" header="Email" title="john@framework7" footer="Work" after="Edit">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
  </List>
  <BlockTitle>Links, no icons</BlockTitle>
  <List>
    <ListItem link="#" title="Ivan Petrov"></ListItem>
    <ListItem link="#" title="John Doe"></ListItem>
    <ListItem divider title="Divider Here"></ListItem>
    <ListItem link="#" title="Ivan Petrov"></ListItem>
    <ListItem link="#" title="Jenna Smith"></ListItem>
  </List>
  <BlockTitle>Grouped with sticky titles</BlockTitle>
  <List ul={false}>
    <ListGroup>
      <ListItem title="A" groupTitle></ListItem>
      <ListItem title="Aaron "></ListItem>
      <ListItem title="Abbie"></ListItem>
      <ListItem title="Adam"></ListItem>
    </ListGroup>
    <ListGroup>
      <ListItem title="B" groupTitle></ListItem>
      <ListItem title="Bailey"></ListItem>
      <ListItem title="Barclay"></ListItem>
      <ListItem title="Bartolo"></ListItem>
    </ListGroup>
    <ListGroup>
      <ListItem title="C" groupTitle></ListItem>
      <ListItem title="Caiden"></ListItem>
      <ListItem title="Calvin"></ListItem>
      <ListItem title="Candy"></ListItem>
    </ListGroup>
  </List>
  <BlockTitle>Mixed and nested</BlockTitle>
  <List>
    <ListItem link="#" title="Ivan Petrov" after="CEO">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Two icons here">
      <i slot="media" class="icon demo-list-icon" />
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem title="No icons here"></ListItem>
    <li>
      <ul>
        <ListItem link="#" title="Ivan Petrov" after="CEO">
          <i slot="media" class="icon demo-list-icon" />
        </ListItem>
        <ListItem link="#" title="Two icons here">
          <i slot="media" class="icon demo-list-icon" />
          <i slot="media" class="icon demo-list-icon" />
        </ListItem>
        <ListItem title="No icons here"></ListItem>
        <ListItem link="#" title="Ultra long text goes here, no, it is really really long">
          <i slot="media" class="icon demo-list-icon" />
        </ListItem>
        <ListItem title="With toggle">
          <i slot="media" class="icon demo-list-icon" />
          <span slot="after">
            <Toggle />
          </span>
        </ListItem>
      </ul>
    </li>
    <ListItem link="#" title="Ultra long text goes here, no, it is really really long">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem title="With toggle">
      <i slot="media" class="icon demo-list-icon" />
      <span slot="after">
        <Toggle />
      </span>
    </ListItem>
  </List>
  <BlockTitle>Mixed, inset</BlockTitle>
  <List>
    <ListItem link="#" title="Ivan Petrov" after="CEO">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Two icons here">
      <i slot="media" class="icon demo-list-icon" />
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Ultra long text goes here, no, it is really really long">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem title="With toggle">
      <i slot="media" class="icon demo-list-icon" />
      <span slot="after">
        <Toggle />
      </span>
    </ListItem>
    <div class="block-footer" slot="after-list">
      <p>Here comes some useful information about list above</p>
    </div>
  </List>
  <BlockTitle>Tablet inset</BlockTitle>
  <List mediumInset>
    <ListItem link="#" title="Ivan Petrov" after="CEO">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Two icons here">
      <i slot="media" class="icon demo-list-icon" />
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <ListItem link="#" title="Ultra long text goes here, no, it is really really long">
      <i slot="media" class="icon demo-list-icon" />
    </ListItem>
    <div class="block-footer" slot="after-list">
      <p>This list block will look like "inset" only on tablets (iPad)</p>
    </div>
  </List>

  <BlockTitle>Media Lists</BlockTitle>
  <Block>
    <p>Media Lists are almost the same as Data Lists, but with a more flexible layout for visualization of more complex data, like products, services, userc, etc.</p>
  </Block>
  <BlockTitle>Songs</BlockTitle>
  <List mediaList>
    <ListItem
      link="#"
      title="Yellow Submarine"
      after="$15"
      subtitle="Beatles"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    >
      <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-1.jpg" width="80" />
    </ListItem>
    <ListItem
      link="#"
      title="Don't Stop Me Now"
      after="$22"
      subtitle="Queen"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    >
      <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-2.jpg" width="80" />
    </ListItem>
    <ListItem
      link="#"
      title="Billie Jean"
      after="$16"
      subtitle="Michael Jackson"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    >
      <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-3.jpg" width="80" />
    </ListItem>
  </List>
  <BlockTitle>Mail App</BlockTitle>
  <List mediaList>
    <ListItem
      link="#"
      title="Facebook"
      after="17:14"
      subtitle="New messages from John Doe"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    ></ListItem>
    <ListItem
      link="#"
      title="John Doe (via Twitter)"
      after="17:11"
      subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    ></ListItem>
    <ListItem
      link="#"
      title="Facebook"
      after="16:48"
      subtitle="New messages from John Doe"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    ></ListItem>
    <ListItem
      link="#"
      title="John Doe (via Twitter)"
      after="15:32"
      subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
      text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
    ></ListItem>
  </List>
  <BlockTitle>Something more simple</BlockTitle>
  <List mediaList>
    <ListItem
      title="Yellow Submarine"
      subtitle="Beatles">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-1.jpg" width="44" />
    </ListItem>
    <ListItem
      link="#"
      title="Don't Stop Me Now"
      subtitle="Queen">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-2.jpg" width="44" />
    </ListItem>
    <ListItem
      title="Billie Jean"
      subtitle="Michael Jackson">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-3.jpg" width="44" />
    </ListItem>
  </List>
  <BlockTitle>Inset</BlockTitle>
  <List mediaList inset>
    <ListItem
      link="#"
      title="Yellow Submarine"
      subtitle="Beatles">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-4.jpg" width="44" />
    </ListItem>
    <ListItem
      link="#"
      title="Don't Stop Me Now"
      subtitle="Queen">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-5.jpg" width="44" />
    </ListItem>
    <ListItem
      link="#"
      title="Billie Jean"
      subtitle="Michael Jackson">
      <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-6.jpg" width="44" />
    </ListItem>
  </List>
</Page>
  

<style>
  :global(.demo-list-icon, .icon-f7) {
    background: #ccc;
    display: block;
    position: relative;
  }
  :global(.ios .demo-list-icon, .ios .icon-f7, .ios .icon-vi) {
    width: 29px;
    height: 29px;
    border-radius: 6px;
    box-sizing: border-box;
  }
  :global(.md .demo-list-icon, .md .icon-f7, .md .icon-vi) {
    width: 24px;
    height: 24px;
    border-radius: 4px;
  }
  :global(.aurora .demo-list-icon, .aurora .icon-f7, .aurora .icon-vi) {
    width: 18px;
    height: 18px;
    border-radius: 4px;
  }
</style>
<script>
  import {Page, Navbar, BlockTitle, List, ListItem, Icon, ListGroup, Toggle, BlockFooter, Block} from 'framework7-svelte';
</script>