🪟 Windows TippsID.3 GTI: VW stellt den stärksten Serien-GTI aller Zeiten vor(16.09.2026 um 10:00 Uhr)
🪟 Windows TippsDoppelte Power: HMX 6 mit 2x RTX 5090 von ZOTAC GAMING(16.09.2026 um 10:25 Uhr)
🪟 Windows TippsAnthbot N8 im Test: Mähroboter mit Fangkorb für Gras und Laub(16.09.2026 um 10:30 Uhr)
🪟 Windows TippsGenesung, Erholung, Entspannung – Aufgaben der Beleuchtung(16.09.2026 um 10:30 Uhr)
🪟 Windows TippsID.3 GTI: VW stellt den stärksten Serien-GTI aller Zeiten vor(16.09.2026 um 10:00 Uhr)
🪟 Windows TippsDoppelte Power: HMX 6 mit 2x RTX 5090 von ZOTAC GAMING(16.09.2026 um 10:25 Uhr)
🪟 Windows TippsAnthbot N8 im Test: Mähroboter mit Fangkorb für Gras und Laub(16.09.2026 um 10:30 Uhr)
🪟 Windows TippsGenesung, Erholung, Entspannung – Aufgaben der Beleuchtung(16.09.2026 um 10:30 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 4 Min Lesezeit
0

Using Blocks in Sections

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Introduction:



Welcome to the third tutorial in the Fynd Platform Theme Development series. In this session, we will focus on blocks, a crucial part of building modular, reusable, and customizable theme sections. By the end of this tutorial, you’ll understand how to define blocks, use them in sections, and leverage their capabilities to create dynamic and merchant-configurable content.






1. What Are Blocks?



Blocks represent individual configurable units within a section. A section can contain multiple blocks, each with its own properties. For example:




  • A banner section might contain blocks for images and captions.

  • A product slider section might have blocks for each product card.



Blocks are defined in the settings.blocks array of a section's configuration file.






2. Anatomy of a Block



Each block consists of:




  • label: Describes the block in the theme editor.

  • type: Specifies the block type (e.g., image, text, range).

  • props: Contains the configurable properties of the block.



Example block configuration:




CODE
blocks: [
{
label: "Image Card",
type: "gallery",
props: [
{
id: "image_url",
label: "Image URL",
type: "image_picker",
default: "",
info: "Upload or select an image for this card."
},
{
id: "alt_text",
label: "Alt Text",
type: "text",
default: "Alt Text",
info: "Text describing the image for accessibility."
},
{
id: "caption",
label: "Caption",
type: "text",
default: "Enter caption here",
info: "Caption displayed below the image."
}
]
}
]









3. Using Blocks in a Section



To use blocks in a section:




  1. Define Blocks in the Section Settings
    Add the blocks configuration in the settings object of your section:




CODE
export const settings = {
label: "Image Gallery",
blocks: [
{
label: "Image Card",
type: "gallery",
props: [
{
id: "url",
label: "Image URL",
type: "image_picker",
default: "",
info: "Upload an image."
},
{
id: "caption",
label: "Caption",
type: "text",
default: "Default Caption",
info: "Caption for the image."
}
]
}
],
props: [],
};







  1. Access Blocks in the Component
    Use the blocks prop passed to the section's component to render block data:




CODE
import React from "react";

export function Component({ blocks }) {
if (!blocks || blocks.length === 0) return null;

return (
<div className="image-gallery">
{blocks.map((block, index) => (
<div key={index} className="image-card">
<img src={block.props.url.value} alt={block.props.caption.value} />
<p>{block.props.caption.value}</p>
</div>
))}
</div>
);
}









4. Advanced Block Features



Default Values

Default values ensure blocks have initial data when no input is provided. For example:




CODE
props: [
{
id: "heading",
label: "Heading",
type: "text",
default: "Welcome to our Store",
info: "Text displayed as the section heading."
}
]






Multiple Block Types

A section can define multiple block types:




CODE
blocks: [
{
label: "Banner",
type: "banner",
[/* ... */]
},
{
label: "Product Card",
type: "product",
[/* ... */]
}
]









5. Real-Life Use Cases




  1. Banner Section with Multiple Slides
    Each slide is represented as a block with properties like image, title, and link.



Settings:




CODE
blocks: [
{
label: "Slide",
type: "slide",
props: [
{
id: "image",
label: "Image",
type: "image_picker",
default: "",
info: "Upload an image for the slide."
},
{
id: "title",
label: "Title",
type: "text",
default: "",
info: "Title displayed on the slide."
},
{
id: "link",
label: "Link",
type: "url",
default: "",
info: "URL to navigate when the slide is clicked."
}
]
}
]







Rendering:




CODE
export function Component({ blocks }) {
return (
<div className="banner-carousel">
{blocks.map((block, index) => (
<div key={index} className="slide">
<img src={block.props.image.value} alt={block.props.title.value} />
<h3>{block.props.title.value}</h3>
<a href={block.props.link.value}>Learn More</a>
</div>
))}
</div>
);
}







  1. Product Grid with Configurable Items



Each product is a block containing properties like image, name, and price.



Settings:




CODE
blocks: [
{
label: "Product",
type: "product",
props: [
{ id: "image", label: "Image", type: "image_picker", default: "" },
{ id: "name", label: "Name", type: "text", default: "" },
{ id: "price", label: "Price", type: "text", default: "" }
]
}
]






Rendering:




CODE
export function Component({ blocks }) {
return (
<div className="product-grid">
{blocks.map((block, index) => (
<div key={index} className="product-card">
<img src={block.props.image.value} alt={block.props.name.value} />
<h4>{block.props.name.value}</h4>
<p>${block.props.price.value}</p>
</div>
))}
</div>
);
}









6. Best Practices




  • Keep Blocks Modular: Define distinct block types for different use cases.

  • Optimize for Reusability: Use generic and reusable block settings to minimize redundancy.

  • Use Defaults Smartly: Always set meaningful default values to enhance the out-of-box experience.

  • Validate Inputs: Ensure inputs are validated to avoid errors during rendering.






Conclusion:



Blocks are powerful tools for creating dynamic and customizable themes on the Fynd Platform. By leveraging blocks, you can build modular sections that offer a high degree of flexibility for merchants. Experiment with different block configurations to explore their full potential.



In the next tutorial, we’ll dive into global configurations to manage theme-level settings. See you there!

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
ID.3 GTI: VW stellt den stärksten Serien-GTI aller Zeiten vor
1 Quelle
32 Kerne, 128 GB RAM, 80 TB: Das war unsere Profi-Höllenmaschine HMX Pro
1 Quelle
Doppelte Power: HMX 6 mit 2x RTX 5090 von ZOTAC GAMING
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Using Blocks in Sections

Thematisch verwandte Begriffe: Using, Blocks, Sections · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...