Skip to content

Commit 286e521

Browse files
Merge pull request #6647 from syncfusion-content/983306-dev-style-fupl
983306: Re-structing the style customization section of File uploader.
2 parents 60c7d65 + 95dbc4d commit 286e521

8 files changed

+106
-30
lines changed

blazor-toc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,8 +2983,8 @@
29832983
<li> <a href="/blazor/file-upload/file-source">File Source</a></li>
29842984
<li> <a href="/blazor/file-upload/template">Template</a></li>
29852985
<li> <a href="/blazor/file-upload/validation">Validation</a></li>
2986-
<li> <a href="/blazor/file-upload/style-appearance">Style and Appearance</a></li>
29872986
<li> <a href="/blazor/file-upload/form-integration">Form Integration</a></li>
2987+
<li> <a href="/blazor/file-upload/style-appearance">File Upload Customization</a></li>
29882988
<li> <a href="/blazor/file-upload/http-client">Http Client</a></li>
29892989
<li>How To
29902990
<ul>
@@ -5006,4 +5006,4 @@
50065006
</li>
50075007
</ul>
50085008
</li>
5009-
</ul>
5009+
</ul>
7.15 KB
Loading
6.45 KB
Loading
4.29 KB
Loading
3.56 KB
Loading
220 KB
Loading
93.4 KB
Loading
Lines changed: 104 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,137 @@
11
---
22
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.
55
platform: Blazor
66
control: File Upload
77
documentation: ug
88
---
99

10-
# Style and appearance in Blazor File Upload Component
10+
# File Uploader Customization in Blazor
1111

12-
The following examples show the CSS selector structure used to customize the File Upload component’s appearance based on user preference. Add these rules after the theme stylesheet so overrides take effect. For scoped styling, wrap the uploader with a custom parent class and prefix selectors to avoid global changes.
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.
1313

14-
## Customizing the appearance of File Upload container element
14+
## CssClass Property
1515

16-
Use the following CSS to customize the overall File Upload container (control wrapper) size. Adjust width and height to fit the desired layout.
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+
![Blazor File Upload with custom styles applied using CssClass](./images/blazor-file-upload-cssclass.png)
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.
1748

1849
```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;
2355
}
2456
```
2557

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+
![Blazor File Upload with a customized container size](./images/blazor-file-upload-container.png)
61+
62+
## Customizing the Browse Button
2763

28-
Use the following CSS to customize the browse and action buttons (font, size, and colors). Consider adding hover and focus styles that meet contrast requirements for accessibility.
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.
2965

3066
```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;
3773
}
3874
```
3975

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+
![Blazor File Upload with a customized Browse button](./images/blazor-file-upload-browser.png)
4179

42-
Use the following CSS to customize the drop area text (content) inside the uploader, including font size and color.
80+
## Customizing the Content Area
81+
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`.
4383

4484
```css
4585
/* 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;
4989
}
5090
```
5191

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" %}
93+
94+
![Blazor File Upload with a customized content area](./images/blazor-file-upload-content.png)
5395

54-
Use the following CSS to customize the appearance of the uploaded file list container (for example, background color). To target specific states (success, error, in-progress), add additional selectors as needed.
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.
5599

56100
```css
57-
/* To specify background color */
101+
/* To specify a background color */
58102
.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+
![Blazor File Upload with a customized file list background](./images/blazor-file-upload-file-list.gif)
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;
60125
}
61-
```
126+
```
127+
128+
{% previewsample "https://blazorplayground.syncfusion.com/embed/BNVetaVyzLHkRSPG?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
129+
130+
![Blazor File Upload with a customized progress bar](./images/blazor-file-upload-progress.gif)
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

Comments
 (0)