|
1 | 1 | --- |
2 | 2 | layout: post |
3 | | -title: Style and appearance in Blazor File Upload Component | Syncfusion |
4 | | -description: Checkout and learn here all about Style and appearance in Syncfusion Blazor File Upload component and more. |
| 3 | +title: File Upload Customization in Blazor File Upload Component | Syncfusion |
| 4 | +description: Learn how to style the Syncfusion Blazor File Upload component using CSS to customize its container, buttons, file list, content area, and progress bar. |
5 | 5 | platform: Blazor |
6 | 6 | control: File Upload |
7 | 7 | documentation: ug |
8 | 8 | --- |
9 | 9 |
|
10 | | -# Style and appearance in Blazor File Upload Component |
| 10 | +# File Uploader Customization in Blazor |
11 | 11 |
|
12 | | -The following content provides the exact CSS structure that can be used to modify the control's appearance based on the user preference. |
| 12 | +The visual appearance of the Syncfusion Blazor File Upload component can be extensively customized using CSS to align with your application's theme and style. This document provides a detailed guide to the component's CSS structure, enabling you to tailor its look and feel. By targeting specific CSS classes, you can modify elements such as the container, buttons, drop area, file list, and progress bar. For best results, it is recommended to use the CssClass property to apply a custom class, which helps scope your styles and prevent them from affecting other components. |
13 | 13 |
|
14 | | -## Customizing the appearance of File Upload container element |
| 14 | +## CssClass Property |
15 | 15 |
|
16 | | -Use the following CSS to customize the appearance of File Upload container element. |
| 16 | +The File Upload component allows you to add a custom CSS class to its wrapper element using the [`CssClass`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfUploader.html#Syncfusion_Blazor_Inputs_SfUploader_CssClass) property. This approach helps scope customizations and prevents unintended global style changes. |
| 17 | + |
| 18 | +```csharp |
| 19 | +@using Syncfusion.Blazor.Inputs |
| 20 | + |
| 21 | +<SfUploader CssClass="e-custom-uploader"> |
| 22 | + <UploaderEvents ValueChange="OnChange"></UploaderEvents> |
| 23 | +</SfUploader> |
| 24 | + |
| 25 | +@code{ |
| 26 | + private void OnChange(UploadChangeEventArgs args) |
| 27 | + { |
| 28 | + // here you can get uploaded file data |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +<style> |
| 33 | + .e-custom-uploader { |
| 34 | + border: 3px dotted #554444; |
| 35 | + } |
| 36 | +</style> |
| 37 | +``` |
| 38 | + |
| 39 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/VjVeDkrSTBqHOkfm?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +By using the `e-custom-uploader` class, you can target specific elements within the File Upload component. |
| 44 | + |
| 45 | +## Customizing the Container |
| 46 | + |
| 47 | +Customize the main container of the File Upload component to control its overall dimensions and spacing. To scope your changes, target the custom class assigned via the `CssClass` property followed by the component's default class selectors. |
17 | 48 |
|
18 | 49 | ```css |
19 | | -/* To specify height */ |
20 | | -.e-upload.e-control-wrapper, .e-bigger.e-small .e-upload.e-control-wrapper { |
21 | | - height: 300px; |
22 | | - width: 300px; |
| 50 | +/* To specify a custom height, width and padding */ |
| 51 | +.e-upload.e-control-wrapper { |
| 52 | + height: 200px; |
| 53 | + width: 300px; |
| 54 | + padding: 30px; |
23 | 55 | } |
24 | 56 | ``` |
25 | 57 |
|
26 | | -## Customizing the File Upload browse button |
| 58 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/rXhSDuVSpLzhuZgm?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 59 | + |
| 60 | + |
27 | 61 |
|
28 | | -Use the following CSS to customize the File Upload browse button |
| 62 | +## Customizing the Browse Button |
| 63 | + |
| 64 | +Alter the **Browse** button's appearance by targeting the `.e-file-select-wrap .e-btn` selector within your custom class. This allows you to style properties like `background-color`, `color`, and `font-family` to match your application's design. |
29 | 65 |
|
30 | 66 | ```css |
31 | | -/* To specify font size and color */ |
32 | | -.e-upload .e-file-select-wrap .e-btn, .e-upload .e-upload-actions .e-btn, .e-bigger.e-small .e-upload .e-file-select-wrap .e-btn, .e-bigger.e-small .e-upload .e-upload-actions .e-btn { |
33 | | - font-family: cursive; |
34 | | - height: 40px; |
35 | | - background-color: aquamarine; |
36 | | - color: coral; |
| 67 | +/* To specify font styles, background, and color */ |
| 68 | +.e-upload .e-file-select-wrap .e-btn { |
| 69 | + font-family: 'cursive'; |
| 70 | + height: 40px; |
| 71 | + background-color: #ead228; |
| 72 | + color: #ca3d09; |
37 | 73 | } |
38 | 74 | ``` |
39 | 75 |
|
40 | | -## Customizing the File Upload content |
| 76 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/BZVItYBoTrJQsbao?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +## Customizing the Content Area |
41 | 81 |
|
42 | | -Use the following CSS to customize the File Upload content |
| 82 | +Style the drop zone where users drag and drop files to provide better visual feedback. Use the `.e-file-drop` selector scoped with your custom class to adjust properties like `font-size` and `color`. |
43 | 83 |
|
44 | 84 | ```css |
45 | 85 | /* To specify font size and color */ |
46 | | -.e-upload .e-file-select-wrap .e-file-drop, .e-bigger.e-small .e-upload .e-file-select-wrap .e-file-drop { |
47 | | - font-size: 20px; |
48 | | - color: aqua; |
| 86 | +.e-upload .e-file-select-wrap .e-file-drop { |
| 87 | + font-size: 20px; |
| 88 | + color: aqua; |
49 | 89 | } |
50 | 90 | ``` |
51 | 91 |
|
52 | | -## Customizing the uploaded file container in File Upload |
| 92 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/VZhetarophoebktx?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
53 | 93 |
|
54 | | -Use the following CSS to customize the uploaded file container in File Upload |
| 94 | + |
| 95 | + |
| 96 | +## Customizing the File List |
| 97 | + |
| 98 | +Customize the appearance of the file list that displays selected files. Target the `.e-upload-file-list` selector within your custom class to apply styles like `background-color` to the list container. |
55 | 99 |
|
56 | 100 | ```css |
57 | | -/* To specify background color */ |
| 101 | +/* To specify a background color */ |
58 | 102 | .e-upload .e-upload-files .e-upload-file-list { |
59 | | - background-color: beige; |
| 103 | + background-color: beige; |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/LjrIjEVIphdshIUl?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +## Customizing the Progress Bar |
| 112 | + |
| 113 | +Provide a consistent look during file uploads by customizing the progress bar and its text. Use the `.e-upload-progress-bar` and `.e-progress-bar-text` selectors, scoped with your custom class, to control properties like `background-color` and `font-weight`. |
| 114 | + |
| 115 | +```css |
| 116 | +/* To specify the background color of the progress bar */ |
| 117 | +.e-upload .e-upload-files .e-upload-progress-wrap .e-upload-progress-bar { |
| 118 | + background: green; |
| 119 | +} |
| 120 | + |
| 121 | +/* To specify the color of the progress bar text */ |
| 122 | +.e-upload .e-upload-files .e-upload-progress-wrap .e-progress-bar-text { |
| 123 | + color: #288928; |
| 124 | + font-weight: bold; |
60 | 125 | } |
61 | 126 | ``` |
| 127 | + |
| 128 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/BNVetaVyzLHkRSPG?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +## See Also |
| 133 | + |
| 134 | +* [How to create a responsive, full-height file uploader](https://support.syncfusion.com/kb/article/21232/how-to-create-a-responsive-full-height-file-uploader-in-blazor) |
| 135 | +* [How to customize button text](https://support.syncfusion.com/kb/article/17457/customizing-button-text-in-blazor-file-upload-component) |
| 136 | +* [How to center the Clear and Upload buttons](https://support.syncfusion.com/kb/article/17534/how-to-center-the-clear-and-upload-buttons-in-blazor-file-upload) |
| 137 | +* [How to customize the tooltip for the browse button](https://support.syncfusion.com/kb/article/16150/how-to-customize-tooltip-for-browse-button-in-blazor-file-upload) |
0 commit comments