Introduction to Sections (dev)
A Section represents a configurable UI element for a Deco site. It is essential to understand what this entails for a developer. A Section is atsx
file inside the sections
folder. Additionally, a Section:
- is a Preact component
- has serializable properties
- exports its properties type
export default
). It
receives properties, returns JSX, and is invoked during each rendering of the
defined element.
Let’s explore how we can manipulate these sections and see the changes reflected
in the Admin interface.
1. Open the Hero section
As an example, open theHero.tsx
section in the Admin interface of the site
you created in a previous tutorial.
Click on the </>
icon on the right bar to view the section’s code.
The code for this element is written in HTML with JavaScript, as shown in the
example below.


2. Run your site locally
Follow the environment configuration steps and run your project locally to see the changes you make in the code reflected in the Admin interface.3. Add a new property to the Hero section
Modify the code ofsections/Hero.tsx
to receive a new optional property, the
size
of a CTA button. Add to the CTA
type a new property, size
, which must
be one of these strings: “xs”, “sm”, “md”, and “lg”.



4. Ready to go!
Now you can configureprops
for the Sections in your site and see how they are
rendered. The preview will automatically update if you modify the Section’s code
locally.
To deploy the changes, push your updates to the main branch or publish your
environment in the Admin interface.