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

Prop Type Default Description
<Card> properties
--- --- --- ---
title string Card header content
content string Card content
footer string Card footer content
padding boolean true Adds additional inner padding on card content
outline boolean false Makes Card outline
noShadow boolean false Disables card shadow
noBorder boolean false Disables card border (for outline cards)
expandable boolean false Enables expandable card
expandableAnimateWidth boolean false Enables card content width also animatable and responsive, but can affect performance
expandableOpened boolean false Boolean property indicating whether the expandable card opened or not
animate boolean true Specifies to open expandable card with animation or not
hideNavbarOnOpen boolean Will hide Navbar on expandable card open. By default inherits same app card parameter.
hideToolbarOnOpen boolean Will hide Toolbar on expandable card open. By default inherits same app card parameter.
swipeToClose boolean Allows to close expandable card with swipe. By default inherits same app card parameter.
backdrop boolean Enables expandable card backdrop layer. By default inherits same app card parameter.
backdropEl string Allows to specify custom expandable card backdrop element. This should be a CSS selector of backdrop element, e.g. .card-backdrop.custom-backdrop
closeByBackdropClick boolean When enabled, expandable card will be closed on its backdrop click. By default inherits same app card parameter.
<f7-card-content> properties
padding boolean true Adds additional inner padding
<CardContent> properties
padding boolean true Adds additional inner padding

Card Events

Event Description
<Card> events
--- ---
cardBeforeOpen Event will be triggered right before expandable card starts its opening animation. event.detail.prevent contains function that will prevent card from opening when called
cardOpen Event will be triggered when expandable card starts its opening animation
cardOpened Event will be triggered after expandable card completes its opening animation
cardClose Event will be triggered when expandable card starts its closing animation
cardClosed Event 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. />

16. <BlockTitle>Outline Cards</BlockTitle>
17. <Card
18. outline
19. 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."
20. />
21. <Card
22. outline
23. title="Card header"
24. content="Card with header and footer. Card headers are used to display card titles and footers for additional information or just for custom actions."
25. footer="Card footer"
26. />
27. <Card
28. outline
29. 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. "
30. />

32. <BlockTitle>Styled Cards</BlockTitle>
33. <Card class="demo-card-header-pic">
34. <CardHeader
35. class="no-border"
36. valign="bottom"
37. style="background-image: url(https://cdn.framework7.io/placeholder/nature-1000x600-3.jpg)"
38. >Journey To Mountains</CardHeader>
39. <CardContent>
40. <p class="date">Posted on January 21, 2015</p>
41. <p>Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non felis. Phasellus quis nibh hendrerit...</p>
42. </CardContent>
43. <CardFooter>
44. <Link>Like</Link>
45. <Link>Read more</Link>
46. </CardFooter>
47. </Card>
48. <Card class="demo-card-header-pic">
49. <CardHeader
50. class="no-border"
51. valign="bottom"
52. style="background-image: url(https://cdn.framework7.io/placeholder/people-1000x600-6.jpg)"
53. >Journey To Mountains</CardHeader>
54. <CardContent>
55. <p class="date">Posted on January 21, 2015</p>
56. <p>Quisque eget vestibulum nulla. Quisque quis dui quis ex ultricies efficitur vitae non felis. Phasellus quis nibh hendrerit...</p>
57. </CardContent>
58. <CardFooter>
59. <Link>Like</Link>
60. <Link>Read more</Link>
61. </CardFooter>
62. </Card>

64. <BlockTitle>Facebook Cards</BlockTitle>
65. <Card class="demo-facebook-card">
66. <CardHeader class="no-border">
67. <div class="demo-facebook-avatar"><img src="https://cdn.framework7.io/placeholder/people-68x68-1.jpg" width="34" height="34"/></div>
68. <div class="demo-facebook-name">John Doe</div>
69. <div class="demo-facebook-date">Monday at 3:47 PM</div>
70. </CardHeader>
71. <CardContent padding={false}>
72. <img src="https://cdn.framework7.io/placeholder/nature-1000x700-8.jpg" width="100%"/>
73. </CardContent>
74. <CardFooter class="no-border">
75. <Link>Like</Link>
76. <Link>Comment</Link>
77. <Link>Share</Link>
78. </CardFooter>
79. </Card>
80. <Card class="demo-facebook-card">
81. <CardHeader class="no-border">
82. <div class="demo-facebook-avatar"><img src="https://cdn.framework7.io/placeholder/people-68x68-1.jpg" width="34" height="34"/></div>
83. <div class="demo-facebook-name">John Doe</div>
84. <div class="demo-facebook-date">Monday at 2:15 PM</div>
85. </CardHeader>
86. <CardContent>
87. <p>What a nice photo i took yesterday!</p><img src="https://cdn.framework7.io/placeholder/nature-1000x700-8.jpg" width="100%"/>
88. <p class="likes">Likes: 112    Comments: 43</p>
89. </CardContent>
90. <CardFooter class="no-border">
91. <Link>Like</Link>
92. <Link>Comment</Link>
93. <Link>Share</Link>
94. </CardFooter>
95. </Card>

97. <BlockTitle>Cards With List View</BlockTitle>
98. <Card>
99. <CardContent padding={false}>
100. <List>
101. <ListItem link="#">Link 1</ListItem>
102. <ListItem link="#">Link 2</ListItem>
103. <ListItem link="#">Link 3</ListItem>
104. <ListItem link="#">Link 4</ListItem>
105. <ListItem link="#">Link 5</ListItem>
106. </List>
107. </CardContent>
108. </Card>
109. <Card title="New Releases:">
110. <CardContent padding={false}>
111. <List medial-list>
112. <ListItem
113. title="Yellow Submarine"
114. subtitle="Beatles"
115. >
116. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-4.jpg" width="44"/>
117. </ListItem>
118. <ListItem
119. title="Don't Stop Me Now"
120. subtitle="Queen"
121. >
122. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-5.jpg" width="44"/>
123. </ListItem>
124. <ListItem
125. title="Billie Jean"
126. subtitle="Michael Jackson"
127. >
128. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-88x88-6.jpg" width="44"/>
129. </ListItem>
130. </List>
131. </CardContent>
132. <CardFooter>
133. <span>January 20, 2015</span>
134. <span>5 comments</span>
135. </CardFooter>
136. </Card>

138. <BlockTitle>Expandable Cards</BlockTitle>
139. <Card expandable>
140. <CardContent padding={false}>
141. <div class="bg-color-red" style="height: 300px">
142. <CardHeader textColor="white" class="display-block">
143. Framework7
144. <br />
145. <small style="opacity: 0.7">Build Mobile Apps</small>
146. </CardHeader>
147. <Link cardClose color="white" class="card-opened-fade-in" style="position: absolute; right: 15px; top: 15px" iconF7="multiply_circle_fill" />
148. </div>
149. <div class="card-content-padding">
150. <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>
151. <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>
152. <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>
153. <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>
154. </div>
155. </CardContent>
156. </Card>

158. <Card expandable>
159. <CardContent padding={false}>
160. <div class="bg-color-yellow" style="height: 300px">
161. <CardHeader textColor="black" class="display-block">
162. Framework7
163. <br/>
164. <small style="opacity: 0.7">Build Mobile Apps</small>
165. </CardHeader>
166. <Link cardClose color="black" class="card-opened-fade-in" style="position: absolute; right: 15px; top: 15px" iconF7="multiply_circle_fill" />
167. </div>
168. <div class="card-content-padding">
169. <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>
170. <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>
171. <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>
172. <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>
173. </div>
174. </CardContent>
175. </Card>
176. </Page>

179. <style>
180. :global(.demo-card-header-pic .card-header) {
181. height: 40vw;
182. background-size: cover;
183. background-position: center;
184. color: #fff;
185. }
186. :global(.demo-card-header-pic .card-content-padding .date){
187. color: #8e8e93;
188. }
189. :global(.demo-facebook-card .card-header) {
190. display: block;
191. padding: 10px;
192. }
193. :global(.demo-facebook-card .demo-facebook-avatar) {
194. float: left;
195. }
196. :global(.demo-facebook-card .demo-facebook-name) {
197. margin-left: 44px;
198. font-size: 14px;
199. font-weight: 500;
200. }
201. :global(.demo-facebook-card .demo-facebook-date) {
202. margin-left: 44px;
203. font-size: 13px;
204. color: #8e8e93;
205. }
206. :global(.demo-facebook-card .card-footer) {
207. background: #fafafa;
208. }
209. :global(.theme-dark .demo-facebook-card .card-footer) {
210. background-color: transparent;
211. }
212. :global(.demo-facebook-card .card-footer a) {
213. color: #81848b;
214. font-weight: 500;
215. }
216. :global(.demo-facebook-card .card-content img) {
217. display: block;
218. }
219. :global(.demo-facebook-card .card-content-padding) {
220. padding: 15px 10px;
221. }
222. :global(.demo-facebook-card .card-content-padding .likes) {
223. color: #8e8e93;
224. }
225. </style>
226. <script>
227. import { Page, Navbar, BlockTitle, Card, CardHeader, CardContent, CardFooter, Link, List, ListItem } from 'framework7-svelte';
228. </script>

← Button

Checkbox →