SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Create a Card Component

Define your first component using UI5 Web Components for React.

Overview

🎓 beginner ⏱ 15 min. HTML5BeginnerSAP Fiori

You will learn

  • ✔How to import UI5 Web Components into your application
  • ✔Learn about the usage of props
  • ✔How to use event handling

More from Lukas Harbarth

See all 6 tutorials by Lukas Harbarth →

Prerequisites

Steps

Intro

You will now integrate the first UI5 Web Component into your App. You can find all available UI5 Web Components for React in the Storybook. There you can try out the different components and also take a look at the coding and the available props.


Step 1 Add the Card component to MyApp.tsx
—

First you need to import the components you want to use.

You can check out all available components in the Storybook. Take your time to play around a little, change some props and take a look at the coding.

  1. Start with importing a Card component into your MyApp.tsx file.

    TypeScript
    import { Card } from "@ui5/webcomponents-react";
  2. Now it’s time to use the Card component. Replace the content of your MyApp function with the following code.

    TypeScript
    return (
      <div>
        <Card>This is the content area of the Card</Card>
      </div>
    );  
    

    For now, the Card only contains some text as children, but in the Storybook, you can see that a Card can receive many props.

    Your webpage should now look like this:

    Card01
    Card01

    Your MyApp.tsx file should now look like this :

    TypeScript
    import { Card } from "@ui5/webcomponents-react";
    
    export function MyApp() {
      return (
        <div>
          <Card>This is the content area of the Card</Card>
        </div>
      );
    }
Step 2 Add content to the Card component
+
Step 3 Style your component
+
Step 4 Event handling
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Add the Card component to MyApp.tsx 2. Add content to the Card component 3. Style your component 4. Event handling
Next