Component Examples

Raise your hand if you learn by example?

I certainly do and to get a good grasp on Components, Variants, Slots, (Bricks as Blocks), I would be so grateful if the Bricks team and/or community could kindly share JSON files as a starting point or point us in the right direction of a resource.

TIA

IMO you’d learn the concepts more quickly by starting with the simplest example possible and then work upwards to add complexity as you discover more use cases ( rather than somebody sending you a complicated first example that you need to dissect )

For example..

Level 1 - Create a custom button/link manually using just div element with a icon and text element inside. Change the div to a link and now you have a very commonly used pattern of elements you’ll likely use elsewhere for a clickable link that looks like a button.

Level 2 - (Component) - Turn this entire thing into a component to easily re-use across your site. You’ll want to set up properties for anything that will likely need to change for each time you use it. The button text, the icon and the URL for where it takes you when you click it.

Level 3 - (Varients) - You realise you will need this component in multiple places, but sometimes with slightly different styles. Maybe you want a ‘primary’ and a ‘secondary’ version with different background colors, hover effects. This is where you create a varient and style each one seperatly. Next time you add the component to a new page, you can choose which varient you need to display.

Level 4 - (Slots) - You may realise in some instances, you actually need more than just an icon and text inside your custom button. So you add a ‘slot’ element inside of the component. Now for each instance of the component, you have the option to nest any additional elements, not just the icon/text that you originally added. Slots are useful for content that is going to be unique to each instance, not stuff that needs to be appear in every instance.

Once you understand that part, then you can expand out to other commonly used patterns/groups of elements like call to action sections, sliders, faq accordions, etc etc. Anywhere where you’re reusing patterns of elements, and it’s useful to keep them synced so you can customise them site wide from one place.

4 Likes