App Layout

First thing we should do for our App is to create index.html file with app’s skeleton.

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- Required meta tags-->
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <!-- Color theme for statusbar (Android only) -->
  9. <meta name="theme-color" content="#2196f3">
  10. <!-- Your app title -->
  11. <title>My App</title>
  12. <!-- Path to Framework7 Library CSS Bundle -->
  13. <link rel="stylesheet" href="path/to/framework7.bundle.min.css">
  14. <!-- Path to your custom app styles-->
  15. <link rel="stylesheet" href="path/to/my-app.css">
  16. </head>
  17. <body>
  18. <!-- App Root Element -->
  19. <div id="app"></div>
  20. <script type="text/javascript" src="path/to/app.js"></script>
  21. </body>
  22. </html>

The <div id="app"></div> is where your main app skeleton should be. You can mount its content as a component or (just for example) we can start to write app skeleton right inside of this div:

Basic Layout

Let’s look at the very basic app component layout:

  1. <!-- Main Framework7 App component where we pass Framework7 params -->
  2. <App params={{ theme: 'auto', name: 'My App', id: 'com.demoapp.test' }}>
  3. <!-- Your main view, should have "main" prop -->
  4. <View main>
  5. <!-- Initial Page -->
  6. <Page>
  7. <!-- Top Navbar -->
  8. <Navbar title="Awesome App"></Navbar>
  9. <!-- Toolbar -->
  10. <Toolbar bottom>
  11. <Link>Link 1</Link>
  12. <Link>Link 2</Link>
  13. </Toolbar>
  14. <!-- Page Content -->
  15. <p>Page content goes here</p>
  16. <Link href="/about/">About App</Link>
  17. </Page>
  18. </View>
  19. </App>
  20. <script>
  21. import { App, View, Page, Navbar, Toolbar, Link } from 'framework7-svelte';
  22. </script>

Advanced Layout

Now, let’s look on more advanced layout where we will also add side panels with views and popup

  1. <!-- Main Framework7 App component where we pass Framework7 params -->
  2. <App params={{ theme: 'auto', name: 'My App', id: 'com.demoapp.test' }}>
  3. <!-- Left Panel with "cover" effect -->
  4. <Panel left cover>
  5. <View>
  6. <Page>
  7. <Navbar title="Left Panel"></Navbar>
  8. <Block>
  9. <p>Here comes the left panel text</p>
  10. </Block>
  11. </Page>
  12. </View>
  13. </Panel>
  14. <!-- Right Panel with "reveal" effect -->
  15. <Panel right reveal>
  16. <View>
  17. <Page>
  18. <Navbar title="Right Panel"></Navbar>
  19. <Block>
  20. <p>Here comes the right panel text</p>
  21. </Block>
  22. </Page>
  23. </View>
  24. </Panel>
  25. <!-- Main view -->
  26. <View main>
  27. <Page>
  28. <Navbar title="Awesome App"></Navbar>
  29. <!-- Page content -->
  30. <Block>
  31. <p>Here comes main view page text</p>
  32. </Block>
  33. <!-- Buttons to open panels -->
  34. <Row>
  35. <Col>
  36. <Button panelOpen="left">Left Panel</Button>
  37. </Col>
  38. <Col>
  39. <Button panelOpen="right">Right Panel</Button>
  40. </Col>
  41. </Row>
  42. <!-- Button to open popup -->
  43. <Button popupOpen="#my-popup">Open Popup</Button>
  44. </Page>
  45. </View>
  46. <!-- Popup. All modals should be outside of Views -->
  47. <Popup id="my-popup">
  48. <View>
  49. <Page>
  50. <Navbar title="Popup">
  51. <!-- Link to close popup -->
  52. <NavRight>
  53. <Link popupClose>Close</Link>
  54. </NavRight>
  55. </Navbar>
  56. <Block>
  57. <p>Here comes popup text</p>
  58. </Block>
  59. </Page>
  60. </View>
  61. </Popup>
  62. </App>
  63. <script>
  64. import { App, NavRight, Panel, View, Page, Navbar, Block, Row, Col, Button, Popup, Link } from 'framework7-svelte';
  65. </script>

You can read more about views, navbar, toolbar, pages, panels and other components in appropriate sections.

Initialize App

Now when we have basic template, we need to initialize our app.

← Package Structure

Initialize App →