FD4B: Create the card and container system
In this chapter, we’ll use auto layout to build a responsive card element for our portfolio’s landing page. Then, we’ll revisit the elements we built in the previous lessons and apply auto layout to them to build a container system for our portfolio. Finally, we’ll wrap things up by turning all of the elements into reusable components.
Create the card element
We’ll start by building the card element. Cards are used to present bite-sized chunks of content in a way that encourages viewers to interact with it to see more details. The name “cards” comes from their resemblance to physical cards—like playing cards.
Even if the term is new to you, you probably interact with card elements every day—whether you’re browsing a streaming service, shopping online, or scrolling through your social media feed. Thanks to their modular and flexible nature, cards have quickly become a popular pattern in modern product design.
Our card will be used to showcase past work and give readers an entry point to another page where they can learn more about the project.
The card will include:
- An image to give a visual preview of our work
- A heading for the project name
- A short text description of the project
- A call to action button
Create the card title and description
We'll start by creating the card's title layer:
- Create a new text layer.
- Type
Project title
as placeholder text for the title. - Adjust the following properties:
- Set the Font family to
Inter
- Set the Font weight to
Semi Bold
- Set the Font size to
25
- Set the Line height to
38
- Set the Alignment to
Left
- Set the Font family to
Next, we'll create the card's description.
- Select the layer you just created and use the keyboard shortcut to duplicate it:
- Mac: ⌘ Command D
- Windows: Ctrl D
- Move the new text layer below the title. Don't worry about precise spacing for now.
- Adjust the following properties:
- Font weight to
Medium
- Font size to
20
- Leave the other properties the same
- Font weight to
- Add a short bit of placeholder text for the description.
Add an instance of the button
Now let’s add our button. Instead of using the main component, we’ll add an instance of that component to the canvas.
There are a few different ways you can create an instance of your component:
- Select the main component on the canvas and duplicate it using the keyboard shortcut
- Mac: ⌘ Command D
- Windows: Ctrl D
- Hold down the modifier key and click and drag the main component to duplicate it
- Mac: ⌥ Option
- Windows: Alt
- Open the Assets panel in the left sidebar, and click and drag a component onto the canvas
Whichever method you choose, place the instance below the description text layer and make sure the layers are left aligned. The spacing between layers doesn’t need to be perfect—we’ll fix it using auto layout.
Add an image placeholder
Next, we'll create a rectangle which we'll use as an image placeholder.
- Use the Rectangle tool to click and drag to create a rectangle to the left of the other layers.
- Change its height to
350
. Don't worry about the width for now. - Click the color swatch in the fill section of the properties panel to open the color picker
- Select Image at the top.
- Rename the layer to Thumbnail.
Add auto layout to the card element
Now that we have all the pieces of our card element, it’s time to put them together using auto layout.
Apply auto layout to the description
- Select the text and button layers.
- Press Shift A to add them to an auto layout frame.
- Rename this new frame to Description.
- Make sure the Direction is set to Vertical the Vertical gap is set to
16
. Leave the rest of the auto layout properties as they are.
Add the layers to a parent frame
Now we need to add all of our layers to a parent frame.
- Select both the Description frame and the Thumbnail layer.
- Press Shift A to create a new auto layout frame.
- Rename the frame to
Content
.
You might be wondering why we added the text and button layers to their own frame instead of including everything in a single parent frame. Auto layout frames can only flow in one direction. But our card content has elements that need to flow both horizontally and vertically. Nesting auto layout frames within other auto layout frames lets us create multi-dimensional layouts with elements that flow in different directions.
This nested structure also allows us to set different padding values between objects. We already set the vertical padding between our text and button layers, so now let’s set the horizontal padding between the Thumbnail and Description frame:
- Select the Content frame
- Change the Horizontal gap to
32
.
When adding auto layout to existing layers, the auto layout properties are determined by how the child layers are arranged on the canvas. When we applied auto layout to the text and button layers, Figma automatically set the frame’s direction to Vertical because the layers were arranged in a vertical stack. Because the Thumbnail and Description layers are positioned side-by-side, Figma automatically set the Content frame’s direction to Horizontal.
A child layer’s position on the canvas also determines what the parent frame’s alignment is set to when auto layout is applied. If your Description frame was aligned with the horizontal center of the Thumbnail layer, your alignment may be set to Align left. Make sure the Content frame’s alignment is set to Align top left instead.
Give the parent frame a maximum width
We also need to give the Content frame a maximum width, so that our card element takes up the same amount of horizontal space as the other elements in our portfolio design.
- Select the Content frame.
- In the Auto layout section, open the Width resizing dropdown menu.
- Select Add max width.
- Enter
1000
in the Max width field. This means that the frame can only ever reach a maximum of 1,000 pixels wide regardless of the content inside.
Depending on the length of your text layers, your Description frame may be spreading beyond the Content frame’s bounding box. Let’s fix that.
- Select the Description frame and change the Width resizing to Fill container.
- Leave the height resizing as-is, we don't need to adjust that yet.
- Do the same for the Thumbnail layer. This will allow our description to grow and shrink, while making sure the width of the text content matches the width of the image.
- We'll also lock the thumbnail's aspect ratio so that its dimensions can scale proportionally.
Note: If your text layers are still going beyond the Content frame’s boundaries, you may need to adjust the two text layer’s width resizing directly. Select the two text layers and check to make sure their Width resizing properties are set to Fill container.
Create the container system
We want to add several cards to our portfolio’s landing page, so we’ll turn our card into a component. But before we do that, let’s compare what we’ve created to the finished portfolio design.
The Content frame in our final design is nested inside another frame with auto layout applied. And if we keep looking, we can see that the same can be said for most of the other portfolio elements, including the landing page hero, the text block, and the image block. Let’s explore why we’ve structured them this way.
By adding an additional frame around an element, we can create a container system for our portfolio. A container system turns each element into discrete blocks, making it easy for us to add, reorder, and swap blocks as we build our designs.
We can still change aspects of individual blocks—like updating the content, adding a background fill, or adjusting the top and bottom padding—without worrying how these changes will impact the rest of the content on the page.
Let’s walk through an example to better understand the benefits of using a container system. Imagine a layout with several card elements, and we want to add a background fill behind one card to help emphasize content we want to draw the visitor’s eye to.
If we were to apply the fill directly to the Content frame, the fill will only extend to the frame’s boundary. By adding the element to a container frame, we can ensure the background fill spans the entire page width without impacting the element’s responsiveness, or its alignment on the page.
Now that we know more about container systems, we’ll revisit the elements we built earlier and apply auto layout to them. We’ll also turn each element into a component so they’ll be ready for when we build our final portfolio design.
Finish the card element
We’ll start by completing the card element we were working on in the previous chapter.
- Select the Frame tool.
- Click and drag to create a new frame around the Content frame. Check the layers section in the left sidebar to make sure the Content frame is inside the new frame.
- Rename the new frame to Project card.
- Press Shift A to add auto layout.
- Change the following auto layout properties:
- Set the Alignment to Center.
- Set the Horizontal padding to
24
. - Set the Vertical padding to
56
. - Set the Height resizing to Hug contents.
- Leave the Width resizing set to Fixed. We'll eventually set this to Fill content when we build our final designs.
Revisit the other elements
Alright, it’s time to add the rest of our portfolio elements to containers! Revisiting past work might feel a little repetitive, but design is all about iteration. The time and effort invested now will pay off when we put our final designs together later.
As we update each element in this next section, you’ll notice the auto layout configurations follow a similar pattern. Most elements will have a Max width of 1000
their Horizontal padding set to 24
and their Vertical padding to 56
However, a few key elements will have some slight adjustments to help them stand out, this includes the:
- Landing page hero
- Section heading
- Impactful text block
- Quote block
With that in mind, let's walk through how we'll add this container system to the other elements we've just designed.
Tip: Get your keyboard shortcut hand ready to hit Shift A to add auto layout!
Update the landing page hero
First, we revisit the landing page hero.
- Select the Landing page hero frame and press Shift A to add auto layout.
- Set the Max width to
1000
. - Set the Vertical gap to
24
. - Set both padding options to
0
(zero).
Next, we’ll add the container frame.
- With the Frame tool enabled, click and drag to add a new frame that surrounds the Landing page hero frame.
- Rename this new frame to Personal bio.
- Select the frame and apply auto layout.
- Change the Alignment to
Center
- Set the Horizontal padding to
24
and the Vertical padding to104
. The extra vertical padding emphasizes the bio’s importance, helping it stand out from the other elements. - Select the Landing page hero frame (that's the inner frame in case you're a bit lost) and change the Width resizing to Fill container.
Update the section heading
We’ll tackle the section heading next.
- Select the Section heading text layer and press Shift A.
- Rename the new frame to
Section heading
. - Select the text layer inside the frame.
- Give the layer a max width of
1000
. - Set both resizing properties to
Fill container
.
To create a strong visual relationship between the section heading and the content that follows it, we’ll use different padding values on the top and bottom of the frame.
- Select the Section heading frame.
- Select Individual padding in the auto layout section and set the padding values:
- Left and right padding to
24
. - Top padding to
72
. - Bottom padding to
0
(zero).
- Left and right padding to
Update the paragraph text
We’re making progress!
- Next, select the paragraph text layer and press Shift A.
- Rename the new frame to
Text block
. - Select the text layer inside the frame and give it a Max width of
1000
. - Set the width resizing to
Fill container
. - Select the Text block frame.
- Set the Horizontal padding to
24
and the Vertical padding to56
.
Update the quote block
Great job so far! We'll update quote block next.
- Select the Quote text layer and add auto layout using Shift A.
- Rename the frame to
Quote block
. - Select the text layer and give it a max width of
570
. Recall that we gave this text layer a specific width of570
. That’s because we want the quote block to act as a visual break on the page. - Set the Width resizing to Fill container.
- Select the Quote block frame and change the Horizontal padding to
24
and the Vertical padding to56
.
Update the image
We’re down to our last two elements!
- Select the Image layer and add auto layout with Shift A.
- Rename the new frame to
Image block
- Change the Horizontal padding to
24
and the Vertical padding to56
. - Select the nested image layer, set the Max width to
1000
and the Width resizing to Fill container.
Update the impactful text
We're almost done! For this final element, we actually won't be using the container system is already designed to span the full width of the website. We still have a few steps to do though:
- Select the Impactful text frame and add auto layout with Shift A.
- Change the Horizontal padding to
24
and the Vertical padding to128
. Like in the Personal bio element, this extra chunky vertical padding will help offset this prominent element from other content on the page.
Create multiple components
Our portfolio elements not only look great, but are now responsive. Now comes the fun part—turning them into components!
Instead of creating individual components, we can create components in bulk. You can create up to 100 components at once, which comes in handy right about now.
- Select all of the elements.
- Click the arrow next to Create component in the right sidebar.
- Choose Create multiple components.
Move components to the Components page
To keep our file organized, we’ll move our main components over to the Components page. To do this:
- Click and drag to select all of the components we just created plus the Button component we created earlier.
- Right-click on the selection, hover over Move to page, and select Components.
-
Now that we’ve moved our elements, the Case study desktop frame preset we added earlier should be empty. We won’t be using it again so you can either delete it or save it to use for your own future explorations.
Lesson wrap up
Excellent work! Not only did we use auto layout to design a card element, we also revisited the other portfolio elements and added them to a container system. We finished the lesson by turning our portfolio elements into reusable components and moving them to our dedicated Components page.
Coming up next, we’ll apply what we learned about auto layout and components to build navigation bar and footer elements for our website.