File Uploader styling
The File Uploader is designed to be easily customizable. We’re using global CSS styles and CSS variables to make it simple to change the look and feel of the components. You can customize the File Uploader to match your brand’s design by changing the color scheme, fonts, icons, and other visual elements.
We use OKLCH. It allows changing colors without compromising accessibility and has a wider color range than RGB or HLS. OKLCH is supported in modern browsers; here is the support table: Can I use OKLCH.
RGB fallback is also provided for older browsers.
Quick customization
You can easily customize the File Uploader by switching between light and dark themes. You can also change the primary color to match your brand’s color.
Theme (light/dark)
By default, it conforms to user preference through the media query. To force a
color scheme, apply the uc-light
or the uc-dark
class to the File Uploader.
Primary color
Change these variables to represent your brand’s color. The numbers stand for Lightness, Chroma, and Hue, respectively. Don’t change the Lightness value to maintain the contrast level. We recommend using oklch.com to convert colors.
Deep customization
You can customize variables like colors, fonts, and sizes. They are defined as custom CSS properties.
All color values come in two variants with -light
and -dark
suffixes. For
example:
Upload button
SimpleBtn
component is the default way to open the uploader dialog. It’s
styled independently. Here are the available variables with their default
values:
Font and sizes
Here are the default values for fonts and sizes that you can customize using CSS variables:
Light colors
Here are the default light colors that you can customize using CSS variables:
Dark colors
Here are the default dark colors that you can customize using CSS variables:
RGB fallback
We provide RGB fallback for older browsers. When you update the primary color using OKLCH, the RGB fallback values remain the same as the default ones.
If you want to change the primary color for RGB fallback values too, you need to
place them in the separate @supports
selector.
There are two special CSS variables for the RGB primary color fallback:
--uc-primary-rgb-light
and --uc-primary-rgb-dark
.
Specific elements customization
To customize some specific elements, you must find them using the browser developer tools and apply custom CSS rules.
For example, to hide the “Clear” button in the upload list, you can use the following CSS rule:
Icons
We’re using SVG sprites to display icons. All the default icons are bundled in the package and injected into the DOM as a hidden SVG element on the initialization stage.
To customize the icons, you can use the iconHrefResolver
option. It’s a
function that resolves the icon sprite URL by its name. The function receives
the icon name as an argument and should return the URL of the icon sprite.
Returned URL will be used as a href
attribute of the <use>
element in the
SVG icon.
Type definition: (iconName: string) => (string | undefined)
So, for example, we want to replace the upload
icon with a custom one. To
achieve this, we need to create a custom icon sprite:
Here we’ve created a custom icon sprite with the my-custom-upload-icon
ID. Now
we need to host this sprite somewhere or inline it into the page.
Let’s go with the hosting option. Place the sprite on your server and name it
my-custom-icons.svg
. Now we can use the iconHrefResolver
option to replace
the default upload
icon with our custom one:
Now the File Uploader will use the custom icon for the upload button.
So how to know the name of the icon you want to replace? You could find the
needed uc-icon
tag in the DOM and check the name
attribute.
All available icons are listed in the repository: