LogoLogo
Quest HomeSign Up
  • 😀Welcome to Quest
  • Getting Started
    • Quest Overview
    • Helpful Resources
    • Quick Start - Build your first component from Figma
    • Quick Start - Build your first component from a Wireframe
    • AI Prompt
  • Fundamentals
    • Customizing & Using the UI Kit
    • Designing Custom Components in Figma
    • Easily Sync Designs without Losing Work
    • Setting Up Props & Bindings
    • Exporting Code
    • Push to your Repository
    • Creating Responsive Components
    • Nesting Components
    • Workspaces & Apps
    • Code & Preview Mode
    • Prototypes/Wireframes
    • Animations - build with React Spring
    • Quest plugin for Figma Dev Mode
    • Publish on Quest to a URL
  • Features
    • Working with Variants & States
    • Naming Conventions
    • Previewing with Custom Fonts
    • Light & Dark Mode
    • Creating a custom Tooltip
    • Creating a Floating Popover
    • Creating a Dialog pop-up
    • Radio Group
    • Using the MUI Data Grid & Table
    • Data & List Bindings
    • Dynamic Bindings
    • Grid
    • File Upload
    • Design System Tab and Theme Import
    • How-to use a Theme in your Application
    • Accessibility Support
    • Design Tips and Tricks
    • Video
    • Lazy Loading
    • Sticky Position
    • Link
    • Custom Breakpoints
    • Min / Max Width
    • Supported Quest UI Kit Components & How-to Make Edits in Figma
    • Supported Chakra Components & How-to Make Edits in Figma
  • Advanced Tutorials
    • Setting up Bindings and Features on the MUI Button
    • Display Repeating Components based on a Dynamic List
    • How-to Pass Values from Parent to Nested Components
    • How-to Invoke a modal Dialog Box from a Button Click
    • How to Setup a popover
  • 🔍Help
    • Product Updates
    • FAQs
    • Plugin Warnings / Alerts
  • 💡Support
    • Why does my design look different in Quest than Figma?
    • Can I keep making changes in Figma without affecting code?
    • What are some best practices?
    • Does Quest support more than Figma and React?
    • How do I manage users?
    • What is the refund process?
    • How do I get in touch with Quest?
    • Do I have to use MUI if I'm using Quest?
Powered by GitBook
On this page

Was this helpful?

  1. Advanced Tutorials

How-to Pass Values from Parent to Nested Components

PreviousDisplay Repeating Components based on a Dynamic ListNextHow-to Invoke a modal Dialog Box from a Button Click

Last updated 2 years ago

Was this helpful?

Use case: Pass values from parent to child components

TL;DR: Here are some high-level steps on how to do this. Look in the next section if you are looking for detailed instructions:

  1. Create a component with a simple element such as an Alert. Define the “text” and “visible” bindings and set the values to default from props such as props.alertText and props.isVisible. Define these props at the component level.

  2. Embed the component created in step 1 into another component i.e. parent component.

  3. In the parent component, add the “Nested Prop Values” binding to pass the values from the parent to the child component.

Detailed Instructions: In this example, we’ll demonstrate how to nest a component under a parent component and pass values to the child component from the parent.

Step 1:

Create a simple Figma Component with one Alert and a frame around it. We recommend you use the button from the MUI (community or paid) kit. This will be the child component that’ll be nested in another component.

Step 2:

Invoke the Quest plugin from within Figma, and Export the Component in Quest. When done, click on the “View in Quest” button to see the component in Quest.

Step 3:

In the Quest editor, set the “text” and “visible” bindings as below on the Alert component:

Step 4:

The next step is to define the props at the Component level as below. If you like, you can define a default value for cases where there is no value passed from the parent component.

Step 5:

We are now done with the Child Component. Now let’s create the parent component in Figma as shown below. Make it a simple frame and copy the Child Component into this frame as shown below:

Step 6:

Invoke the Quest plugin from within Figma, and Export the Parent Component into Quest. When done, click on the “View in Quest” button to see the component in Quest.

Step 7:

In the Quest Editor, set the Nested Prop Values binding as shown below. Essentially, we are passing the values to the child component through this binding:

alertText={"Hello text from passed from the Parent component"} isVisible={true}

Step 8:

Final Step 9:

Drop the generated code into your local react environment and test it out. You should see something like below.

Next step is to export the code using the “Download” button as shown below for both the Parent and the Child Component. You can also download the entire App if you prefer.