Cards - 图1

Card Svelte Component

Cards, along with List View, is a one more great way to contain and orginize your information. Cards contains unique related data, for example, a photo, text, and link all about a single subject. Cards are typically an entry point to more complex and detailed information.

Card Svelte component represents Cards component.

Card Components

There are following components included:

  • Card
  • CardHeader
  • CardContent
  • CardFooter

Card Properties

PropTypeDefaultDescription
<Card> properties
titlestringCard header content
contentstringCard content
footerstringCard footer content
paddingbooleantrueAdds additional inner padding on card content
outlinebooleanfalseMakes Card outline
noShadowbooleanfalseDisables card shadow
noBorderbooleanfalseDisables card border (for outline cards)
expandablebooleanfalseEnables expandable card
expandableAnimateWidthbooleanfalseEnables card content width also animatable and responsive, but can affect performance
expandableOpenedbooleanfalseBoolean property indicating whether the expandable card opened or not
animatebooleantrueSpecifies to open expandable card with animation or not
hideNavbarOnOpenbooleanWill hide Navbar on expandable card open. By default inherits same app card parameter.
hideToolbarOnOpenbooleanWill hide Toolbar on expandable card open. By default inherits same app card parameter.
swipeToClosebooleanAllows to close expandable card with swipe. By default inherits same app card parameter.
backdropbooleanEnables expandable card backdrop layer. By default inherits same app card parameter.
backdropElstringAllows to specify custom expandable card backdrop element. This should be a CSS selector of backdrop element, e.g. .card-backdrop.custom-backdrop
closeByBackdropClickbooleanWhen enabled, expandable card will be closed on its backdrop click. By default inherits same app card parameter.
<f7-card-content> properties
paddingbooleantrueAdds additional inner padding
<CardContent> properties
paddingbooleantrueAdds additional inner padding

Card Events

EventDescription
<Card> events
cardBeforeOpenEvent will be triggered right before expandable card starts its opening animation. event.detail.prevent contains function that will prevent card from opening when called
cardOpenEvent will be triggered when expandable card starts its opening animation
cardOpenedEvent will be triggered after expandable card completes its opening animation
cardCloseEvent will be triggered when expandable card starts its closing animation
cardClosedEvent will be triggered after expandable card completes its closing animation

Examples

  1. <Page>
  2. <Navbar title="Cards" />
  3. <BlockTitle>Simple Cards</BlockTitle>
  4. <Card
  5. content="This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element."
  6. />
  7. <Card
  8. title="Card header"
  9. content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
  10. footer="Card footer"
  11. />
  12. <Card
  13. content="Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet. Mauris aliquet magna justo. "
  14. />
  15. <BlockTitle>Outline Cards</BlockTitle>
  16. <Card
  17. outline
  18. content="This is a simple card with plain text, but cards can also contain their own header, footer, list view, image, or any other element."
  19. />
  20. <Card
  21. outline
  22. title="Card header"
  23. content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
  24. footer="Card footer"
  25. />
  26. <Card
  27. outline
  28. content="Another card. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse feugiat sem est, non tincidunt ligula volutpat sit amet. Mauris aliquet magna justo. "
  29. />
  30. <BlockTitle>Styled Cards</BlockTitle>
  31. <Card class="demo-card-header-pic">
  32. <CardHeader
  33. class="no-border"
  34. valign="bottom"
  35. style="background-image: url(https://cdn.framework7.io/placeholder/nature-1000x600-3.jpg)"
  36. >Journey To Mountains</CardHeader>
  37. <CardContent>
  38. <p class="date">Posted on January 21, 2015</p>
  39. <p>Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non felis. Phasellus quis nibh hendrerit...</p>
  40. </CardContent>
  41. <CardFooter>
  42. <Link>Like</Link>
  43. <Link>Read more</Link>
  44. </CardFooter>
  45. </Card>
  46. <Card class="demo-card-header-pic">
  47. <CardHeader
  48. class="no-border"
  49. valign="bottom"
  50. style="background-image: url(https://cdn.framework7.io/placeholder/people-1000x600-6.jpg)"
  51. >Journey To Mountains</CardHeader>
  52. <CardContent>
  53. <p class="date">Posted on January 21, 2015</p>
  54. <p>Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non felis. Phasellus quis nibh hendrerit...</p>
  55. </CardContent>
  56. <CardFooter>
  57. <Link>Like</Link>
  58. <Link>Read more</Link>
  59. </CardFooter>
  60. </Card>
  61. <BlockTitle>Facebook Cards</BlockTitle>
  62. <Card class="demo-facebook-card">
  63. <CardHeader class="no-border">
  64. <div class="demo-facebook-avatar"><img src="https://cdn.framework7.io/placeholder/people-68x68-1.jpg" width="34" height="34"/></div>
  65. <div class="demo-facebook-name">John Doe</div>
  66. <div class="demo-facebook-date">Monday at 3:47 PM</div>
  67. </CardHeader>
  68. <CardContent padding={false}>
  69. <img src="https://cdn.framework7.io/placeholder/nature-1000x700-8.jpg" width="100%"/>
  70. </CardContent>
  71. <CardFooter class="no-border">
  72. <Link>Like</Link>
  73. <Link>Comment</Link>
  74. <Link>Share</Link>
  75. </CardFooter>
  76. </Card>
  77. <Card class="demo-facebook-card">
  78. <CardHeader class="no-border">
  79. <div class="demo-facebook-avatar"><img src="https://cdn.framework7.io/placeholder/people-68x68-1.jpg" width="34" height="34"/></div>
  80. <div class="demo-facebook-name">John Doe</div>
  81. <div class="demo-facebook-date">Monday at 2:15 PM</div>
  82. </CardHeader>
  83. <CardContent>
  84. <p>What a nice photo i took yesterday!</p><img src="https://cdn.framework7.io/placeholder/nature-1000x700-8.jpg" width="100%"/>
  85. <p class="likes">Likes: 112 Comments: 43</p>
  86. </CardContent>
  87. <CardFooter class="no-border">
  88. <Link>Like</Link>
  89. <Link>Comment</Link>
  90. <Link>Share</Link>
  91. </CardFooter>
  92. </Card>
  93. <BlockTitle>Cards With List View</BlockTitle>
  94. <Card>
  95. <CardContent padding={false}>
  96. <List>
  97. <ListItem link="#">Link 1</ListItem>
  98. <ListItem link="#">Link 2</ListItem>
  99. <ListItem link="#">Link 3</ListItem>
  100. <ListItem link="#">Link 4</ListItem>
  101. <ListItem link="#">Link 5</ListItem>
  102. </List>
  103. </CardContent>
  104. </Card>
  105. <Card title="New Releases:">
  106. <CardContent padding={false}>
  107. <List medial-list>
  108. <ListItem
  109. title="Yellow Submarine"
  110. subtitle="Beatles"
  111. >
  112. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-4.jpg" width="44"/>
  113. </ListItem>
  114. <ListItem
  115. title="Don't Stop Me Now"
  116. subtitle="Queen"
  117. >
  118. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-5.jpg" width="44"/>
  119. </ListItem>
  120. <ListItem
  121. title="Billie Jean"
  122. subtitle="Michael Jackson"
  123. >
  124. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-6.jpg" width="44"/>
  125. </ListItem>
  126. </List>
  127. </CardContent>
  128. <CardFooter>
  129. <span>January 20, 2015</span>
  130. <span>5 comments</span>
  131. </CardFooter>
  132. </Card>
  133. <BlockTitle>Expandable Cards</BlockTitle>
  134. <Card expandable>
  135. <CardContent padding={false}>
  136. <div class="bg-color-red" style="height: 300px">
  137. <CardHeader textColor="white" class="display-block">
  138. Framework7
  139. <br />
  140. <small style="opacity: 0.7">Build Mobile Apps</small>
  141. </CardHeader>
  142. <Link cardClose color="white" class="card-opened-fade-in" style="position: absolute; right: 15px; top: 15px" iconF7="multiply_circle_fill" />
  143. </div>
  144. <div class="card-content-padding">
  145. <p>Framework7 - is a free and open source HTML mobile framework to develop hybrid mobile apps or web apps with iOS or Android (Material) native look and feel. It is also an indispensable prototyping apps tool to show working app prototype as soon as possible in case you need to. Framework7 is created by Vladimir Kharlampidi (iDangero.us).</p>
  146. <p>The main approach of the Framework7 is to give you an opportunity to create iOS and Android (Material) apps with HTML, CSS and JavaScript easily and clear. Framework7 is full of freedom. It doesn't limit your imagination or offer ways of any solutions somehow. Framework7 gives you freedom!</p>
  147. <p>Framework7 is not compatible with all platforms. It is focused only on iOS and Android (Material) to bring the best experience and simplicity.</p>
  148. <p>Framework7 is definitely for you if you decide to build iOS and Android hybrid app (Cordova or PhoneGap) or web app that looks like and feels as great native iOS or Android (Material) apps.</p>
  149. </div>
  150. </CardContent>
  151. </Card>
  152. <Card expandable>
  153. <CardContent padding={false}>
  154. <div class="bg-color-yellow" style="height: 300px">
  155. <CardHeader textColor="black" class="display-block">
  156. Framework7
  157. <br/>
  158. <small style="opacity: 0.7">Build Mobile Apps</small>
  159. </CardHeader>
  160. <Link cardClose color="black" class="card-opened-fade-in" style="position: absolute; right: 15px; top: 15px" iconF7="multiply_circle_fill" />
  161. </div>
  162. <div class="card-content-padding">
  163. <p>Framework7 - is a free and open source HTML mobile framework to develop hybrid mobile apps or web apps with iOS or Android (Material) native look and feel. It is also an indispensable prototyping apps tool to show working app prototype as soon as possible in case you need to. Framework7 is created by Vladimir Kharlampidi (iDangero.us).</p>
  164. <p>The main approach of the Framework7 is to give you an opportunity to create iOS and Android (Material) apps with HTML, CSS and JavaScript easily and clear. Framework7 is full of freedom. It doesn't limit your imagination or offer ways of any solutions somehow. Framework7 gives you freedom!</p>
  165. <p>Framework7 is not compatible with all platforms. It is focused only on iOS and Android (Material) to bring the best experience and simplicity.</p>
  166. <p>Framework7 is definitely for you if you decide to build iOS and Android hybrid app (Cordova or PhoneGap) or web app that looks like and feels as great native iOS or Android (Material) apps.</p>
  167. </div>
  168. </CardContent>
  169. </Card>
  170. </Page>
  171. <style>
  172. :global(.demo-card-header-pic .card-header) {
  173. height: 40vw;
  174. background-size: cover;
  175. background-position: center;
  176. color: #fff;
  177. }
  178. :global(.demo-card-header-pic .card-content-padding .date){
  179. color: #8e8e93;
  180. }
  181. :global(.demo-facebook-card .card-header) {
  182. display: block;
  183. padding: 10px;
  184. }
  185. :global(.demo-facebook-card .demo-facebook-avatar) {
  186. float: left;
  187. }
  188. :global(.demo-facebook-card .demo-facebook-name) {
  189. margin-left: 44px;
  190. font-size: 14px;
  191. font-weight: 500;
  192. }
  193. :global(.demo-facebook-card .demo-facebook-date) {
  194. margin-left: 44px;
  195. font-size: 13px;
  196. color: #8e8e93;
  197. }
  198. :global(.demo-facebook-card .card-footer) {
  199. background: #fafafa;
  200. }
  201. :global(.theme-dark .demo-facebook-card .card-footer) {
  202. background-color: transparent;
  203. }
  204. :global(.demo-facebook-card .card-footer a) {
  205. color: #81848b;
  206. font-weight: 500;
  207. }
  208. :global(.demo-facebook-card .card-content img) {
  209. display: block;
  210. }
  211. :global(.demo-facebook-card .card-content-padding) {
  212. padding: 15px 10px;
  213. }
  214. :global(.demo-facebook-card .card-content-padding .likes) {
  215. color: #8e8e93;
  216. }
  217. </style>
  218. <script>
  219. import { Page, Navbar, BlockTitle, Card, CardHeader, CardContent, CardFooter, Link, List, ListItem } from 'framework7-svelte';
  220. </script>

← Button

Checkbox →