A theme app extension is a bundle of app blocks, app embed blocks, assets, and snippets.
## File structure
When you [create a theme app extension](/docs/apps/build/online-store/theme-app-extensions/build), Shopify adds the following `theme-app-extension` directory and subdirectories to your app:
Theme app extension subdirectory descriptions
Subdirectory |
Description |
assets |
Contains CSS, JavaScript, and other static app content that gets injected into themes.
Apps can load assets using either the JavaScript and stylesheet schema attributes or from the asset_url and asset_img_url Liquid URL filters. |
blocks |
Contains app blocks for themes and app embed block Liquid files. |
snippets |
Contains Liquid snippet files for the theme app extension, which are bits of code that you can reference in other app blocks and app embed blocks. |
locales |
Contains JSON locale files to host merchant-facing and customer-facing translations. These files are similar to theme locale files in their schema and usage. You can include the following file types:
- Schema locale files: Contains merchant-facing translations. Use these files to translate the settings that appear in the theme editor.
- Storefront locale files: Contains customer-facing translations. Use these files to translate the text that appears in the storefront when your app block or app embed block is rendered.
Note: Merchants can't edit the strings in theme app extension storefront locale files.
|
shopify.extension.toml |
A configuration file containing basic app configuration settings, including the extension name and type (theme ).
|
## App blocks for themes
Apps that inject inline content on a page extend themes using app blocks. Merchants can add app blocks to a compatible theme section, or as [wrapped](#examples-of-app-blocks-in-a-theme) app blocks that are added at the section level. Create an app block by setting the `target` in the schema to `section`.
By default, themes don't include app blocks after an app is installed. Merchants need to add the app blocks to the theme from the **Apps** section of the [theme editor](/docs/storefronts/themes/tools/online-editor).
> Tip:
> [Build app blocks responsively](https://www.shopify.com/partners/blog/responsive-app-blocks), so that they can adapt to the size of the sections to which they're added.
Use app blocks for the following types of apps:
* Apps that you want to automatically point to dynamic sources, such as product reviews apps and star ratings apps.
* Apps that merchants might want to reposition on a page.
* Apps that should span the full width of a page.
### App block support in themes
For app blocks to function, a theme must contain the following:
* [JSON templates](/docs/storefronts/themes/architecture/templates/json-templates).
* Sections that [support](/docs/storefronts/themes/architecture/blocks/app-blocks#supporting-app-blocks) and [render](/docs/storefronts/themes/architecture/blocks/app-blocks#render-app-blocks) blocks of type `@app`.
Refer to Dawn's [main product section](https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid) for an example implementation.
You can [verify](/docs/apps/build/online-store/verify-support) whether a theme supports app blocks
.
### Example app block
The following example creates a `span` element with a `style` attribute. The `style` value (`color: {{ block.settings.color }}`) searches inside of `schema` for a `settings` key, and then searches for a `color` key, which contains the `"default": "#000000"` value. This value then populates the `style` attribute with the default color `#000000`, which renders the `App blocks let you build powerful integrations with online store themes!` text in black.
> Tip:
> For a more complex example, refer to Shopify's [product reviews app](https://github.com/Shopify/product-reviews-sample-app).
### Examples of app blocks in a theme
The following is an example of an app block added to a section:
The following is an example of a wrapped app block:
### Benefits of app blocks
App blocks are flexible. Merchants can use the theme editor to add, remove, and reorder app blocks at the section level for easy customization.
An app block can use [`autofill` resource settings](#autofill) to automatically point to dynamic sources and ensure that content remains in sync with its parent section. For example, an app block on the **Products** page can point to a dynamic source to show data for different products as they display on the page.
## App embed blocks
Apps that don't have a UI component, or that add floating or overlaid elements, extend themes using app embed blocks. Shopify renders and injects app embed blocks before HTML `` and `