xref: /openbmc/webui-vue/docs/guide/quickstart/page-anatomy.md (revision e2707ef0ca20b669aca7ac06274591bd795719a9)
126c8fae0SDixsie Wolmers# Page Anatomy
226c8fae0SDixsie WolmersSingle-file components (SFC) consist of a `template`, `script` and `style` block.
326c8fae0SDixsie Wolmers
426c8fae0SDixsie Wolmers## Template block
526c8fae0SDixsie WolmersWhen creating a new page, each template consists of at least 3 components:
626c8fae0SDixsie Wolmers- `<b-container>`
726c8fae0SDixsie Wolmers- `<page-title>`
826c8fae0SDixsie Wolmers- `<page-section>`
926c8fae0SDixsie Wolmers
10*e2707ef0SDixsie WolmersLearn more about the [page container, page title and page section](/guide/components/page) components.
1126c8fae0SDixsie Wolmers
1226c8fae0SDixsie Wolmers```vue
1326c8fae0SDixsie Wolmers<template>
1426c8fae0SDixsie Wolmers  <b-container fluid="xl">
15*e2707ef0SDixsie Wolmers    <page-title />
1626c8fae0SDixsie Wolmers    <page-section :section-title="$t('pageName.sectionTitle')">
1726c8fae0SDixsie Wolmers      // Page content goes here
1826c8fae0SDixsie Wolmers    </page-section>
1926c8fae0SDixsie Wolmers  </b-container>
2026c8fae0SDixsie Wolmers</template>
2126c8fae0SDixsie Wolmers```
2226c8fae0SDixsie Wolmers## Scripts block
2326c8fae0SDixsie WolmersIn the scripts section, be sure to import the `PageTitle` and `PageSection` components and declare them in the `components` property.
24*e2707ef0SDixsie Wolmers
25*e2707ef0SDixsie WolmersImporting `BContainer` in the [scripts block](#scripts-block) is not required as it is already registered globally.
26*e2707ef0SDixsie Wolmers
2726c8fae0SDixsie Wolmers```vue
2826c8fae0SDixsie Wolmers<script>
2926c8fae0SDixsie Wolmersimport PageTitle from '@/components/Global/PageTitle';
3026c8fae0SDixsie Wolmersimport PageSection from '@/components/Global/PageSection';
3126c8fae0SDixsie Wolmersexport default {
3226c8fae0SDixsie Wolmers  name: 'PageName',
3326c8fae0SDixsie Wolmers  components: { PageTitle, PageSection }
3426c8fae0SDixsie Wolmers};
3526c8fae0SDixsie Wolmers</script>
3626c8fae0SDixsie Wolmers```
3726c8fae0SDixsie Wolmers
3826c8fae0SDixsie Wolmers## Style block
3926c8fae0SDixsie WolmersAdd the `scoped` attribute to the style block to keep the styles isolated to the SFC. While the `scoped` attribute is optional, it is preferred and global changes should be done in global style sheets.
4026c8fae0SDixsie Wolmers```vue
4126c8fae0SDixsie Wolmers<style lang="scss" scoped> </style>
4226c8fae0SDixsie Wolmers```
4326c8fae0SDixsie Wolmers
4426c8fae0SDixsie Wolmers## Complete single-file component (SFC)
4526c8fae0SDixsie WolmersThe final SFC will look like this.
4626c8fae0SDixsie Wolmers```vue
4726c8fae0SDixsie Wolmers<template>
4826c8fae0SDixsie Wolmers  <b-container fluid="xl">
4926c8fae0SDixsie Wolmers    <page-title :description="$t('pageName.pageDescription')"/>
5026c8fae0SDixsie Wolmers    <page-section :section-title="$t('pageName.sectionTitle')">
5126c8fae0SDixsie Wolmers      // Page content goes here
5226c8fae0SDixsie Wolmers    </page-section>
5326c8fae0SDixsie Wolmers  </b-container>
5426c8fae0SDixsie Wolmers</template>
5526c8fae0SDixsie Wolmers<script>
5626c8fae0SDixsie Wolmersimport PageTitle from '@/components/Global/PageTitle';
5726c8fae0SDixsie Wolmersimport PageSection from '@/components/Global/PageSection';
5826c8fae0SDixsie Wolmersexport default {
5926c8fae0SDixsie Wolmers  name: 'PageName',
6026c8fae0SDixsie Wolmers  components: { PageTitle, PageSection }
6126c8fae0SDixsie Wolmers};
6226c8fae0SDixsie Wolmers</script>
6326c8fae0SDixsie Wolmers<style lang="scss" scoped>
6426c8fae0SDixsie Wolmers    .example-class {
6526c8fae0SDixsie Wolmers      /* Styles go here */
6626c8fae0SDixsie Wolmers    }
6726c8fae0SDixsie Wolmers </style>
6826c8fae0SDixsie Wolmers```