--- title: "Setting a CSS class for a App Designer component" slug: "setting-a-css-class-for-a-app-designer-component" updated: 2024-01-11T12:33:46Z published: 2024-01-11T12:33:46Z canonical: "help.pillir.io/setting-a-css-class-for-a-app-designer-component" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.pillir.io/llms.txt > Use this file to discover all available pages before exploring further. # Methods of Applying a CSS class for App Designer components Q: What is the recommended approach to add a CSS class for an App Designer component? A: The Style or Format changes for a component can be done using the **Style** property of the component. The CSS class can be applied in the following ways: ## **Assigning an inline class** This method refers to adding a custom CSS for the component directly in the Style properties section. It is used when the applied format is constant for the component and does not require any future changes. To add custom css for a button component, do the following: 1. Click the button component and in the Style property section, enter the following css code in the **Custom CSS** field. ```css float: right; color: pink; background-color: #808080; ``` ![button%20component](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/button%20component.png) ## **Adding a CSS class imported from Library >Assets** 1. Add the required css class in the **Class.css** file.![classcss](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/classcss.png) 2. Upload the file in **Library > Assets** section and share it to the project where the business function is created.![apply%20to%20project](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/apply%20to%20project.png) 3. Click the component and in the Style property section, enter the **class name** - **eg: one** | Before applying class | After applying class | | --- | --- | | ![beforeclass%20apply](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/beforeclass%20apply.png) | ![class-applied](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/class-applied.png) | The new class is now applied for the selected datagrid component. ## **Assigning a class through a variable** This method allows you to add a dynamic class by assigning it to a variable. For example: If you need to add a background color to a text component on the click of a button, you can add the related class through a variable. 1. Drag and drop a **Text** component. Modify properties as shown in image.![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/textcomp.png) 2. Create a **className** variable in the "Add Variables" section. 3. In the Style properties of the Text component, map the className variable.![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/textcomp-classname%20map.png) 4. Add a **Button** component. Enter a **Title** name.![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/textcomp-button.png) 5. Open the **Behavior** tab of the Button component. Add the logic as shown in image.![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/textcom--button-behav.png) ("one" is the name of the css class added in the **Class.css** file and stored in **Library > Assets** section. We are referencing it to the className variable) 1. Now when the button is clicked, the background color of the Text component changes. This action can be checked in the App Preview.![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/textcomp-preview.png) NoteWhen working with components, refrain from adding classes through separate logic (App behaviors). Instead, opt to add through the above methods, as it enhances maintainability and promotes design consistency.