Amplify Studio offers visual data binding capabilities to bind UI components to data to build dynamic components. Use the UI component editor to map fields to static values, or map fields to your backend data model. All data bindings get automatically included in generated code.
UI component editorThe UI component editor allows you to bind elements in your component to actual data.
1. Elements treeThe elements tree shows the composition of the component in Figma. Each layer in Figma maps to a specific Amplify UI primitive. For example, a frame in Figma maps to a <Flex>
component in the Amplify UI library. Clicking on a layer will highlight the element in the live preview.
The live preview is a representation of the React component! If you inspect the component in the browser developer tools, you will see that each element in the component maps to real code. Click on any element within a component to select a specific child component. This will highlight the layer in the elements tree as well as bring up all relevant child properties for that component.
3. Component propertiesJust like in React, you can set props on your parent component. React components use props to communicate with each other. Every parent component can pass some information to its child components by giving them props. To learn more about React props visit their documentation. Amplify Studio supports Scalar (String, Number, Boolean) and Data model component types.
4. Child propertiesClicking on any child elements within the live preview allows you to set child prop values. You can either set static values or pass prop values from the parent component. Child props will map to props available on the UI primitives. For example, if you select a <Button>
component, you will be able to set props such as variation
, size
and see the live preview update with the values.
You can perform the following actions on a component:
With Amplify Studio, you can bind elements in your UI component to actual backend data from your database by passing component properties with a Data model type down to the child elements.
You need to deploy a data model in order to bind to data. Studio supports any GraphQL API created with Amplify, with and without DataStore.
foo
. Reference your data model (e.g. Home
) as the type.src
, and for value, link to home.image_url
. The live preview should update to an image from your database. Continue to repeat the same steps for different child elements such as text fields, inputs etc.Learn more in the Collections documentation
Bind UI to static dataYou can bind text labels to static values. Use one of the following two methods to bind UI elements to static values.
Pass component property default value to child propsThe following example demonstrates how to set the text label's value to the component's default value.
foo
of type String
with a default value of Hello world
.label
and for value, link to foo
. The live preview should update to display "Hello world".You can directly set child prop values with all available properties. In the following example, you are setting the label
prop to "Explore" and the color
prop to "orange".
Modifiers let you apply custom logic to renders child prop values.
ConditionalsYou can apply conditional logic on values of child props. The following example demonstrates how you can conditionally set the value of a child prop based on custom logic.
ConcatenationsYou can apply concatenations on values of child props. The following example demonstrates how to add a $
sign before displaying a price.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4