Utilities

Background Color

The Background Color utility lets you set the background color of UI elements. By default, ZoboUI includes a variety of color classes to help you get started, but you can also add new colors (or remove existing ones) if you want to.

Utility Class
USS Properties
bg-transparent
background-color: rgba(0, 0, 0, 0);
bg-slate-50
background-color: #F8FAFC;
bg-slate-100
background-color: #F1F5F9;
bg-slate-200
background-color: #E2E8F0;
bg-slate-300
background-color: #CBD5E1;
bg-slate-400
background-color: #94A3B8;
bg-slate-500
background-color: #64748B;
bg-slate-600
background-color: #475569;
bg-slate-700
background-color: #334155;
bg-slate-800
background-color: #1E293B;
bg-slate-900
background-color: #0F172A;
bg-slate-950
background-color: #020617;
bg-gray-50
background-color: #F9FAFB;
bg-gray-100
background-color: #F3F4F6;
bg-gray-200
background-color: #E5E7EB;
bg-gray-300
background-color: #D1D5DB;
bg-gray-400
background-color: #9CA3AF;
bg-gray-500
background-color: #6B7280;
bg-gray-600
background-color: #4B5563;
bg-gray-700
background-color: #374151;
bg-gray-800
background-color: #1F2937;
bg-gray-900
background-color: #111827;
bg-gray-950
background-color: #030712;
bg-zinc-50
background-color: #FAFAFA;
bg-zinc-100
background-color: #F4F4F5;
bg-zinc-200
background-color: #E4E4E7;
bg-zinc-300
background-color: #D4D4D8;
bg-zinc-400
background-color: #A1A1AA;
bg-zinc-500
background-color: #71717A;
bg-zinc-600
background-color: #52525B;
bg-zinc-700
background-color: #3F3F46;
bg-zinc-800
background-color: #27272A;
bg-zinc-900
background-color: #18181B;
bg-zinc-950
background-color: #09090B;
bg-neutral-50
background-color: #FAFAFA;
bg-neutral-100
background-color: #F5F5F5;
bg-neutral-200
background-color: #E5E5E5;
bg-neutral-300
background-color: #D4D4D4;
bg-neutral-400
background-color: #A3A3A3;
bg-neutral-500
background-color: #737373;
bg-neutral-600
background-color: #525252;
bg-neutral-700
background-color: #404040;
bg-neutral-800
background-color: #262626;
bg-neutral-900
background-color: #171717;
bg-neutral-950
background-color: #0A0A0A;
bg-stone-50
background-color: #FAFAF9;
bg-stone-100
background-color: #F5F5F4;
bg-stone-200
background-color: #E7E5E4;
bg-stone-300
background-color: #D6D3D1;
bg-stone-400
background-color: #A8A29E;
bg-stone-500
background-color: #78716C;
bg-stone-600
background-color: #57534E;
bg-stone-700
background-color: #44403C;
bg-stone-800
background-color: #292524;
bg-stone-900
background-color: #1C1917;
bg-stone-950
background-color: #0C0A09;
bg-red-50
background-color: #FEF2F2;
bg-red-100
background-color: #FEE2E2;
bg-red-200
background-color: #FECACA;
bg-red-300
background-color: #FCA5A5;
bg-red-400
background-color: #F87171;
bg-red-500
background-color: #EF4444;
bg-red-600
background-color: #DC2626;
bg-red-700
background-color: #B91C1C;
bg-red-800
background-color: #991B1B;
bg-red-900
background-color: #7F1D1D;
bg-red-950
background-color: #450A0A;
bg-orange-50
background-color: #FFF7ED;
bg-orange-100
background-color: #FFEDD5;
bg-orange-200
background-color: #FED7AA;
bg-orange-300
background-color: #FDBA74;
bg-orange-400
background-color: #FB923C;
bg-orange-500
background-color: #F97316;
bg-orange-600
background-color: #EA580C;
bg-orange-700
background-color: #C2410C;
bg-orange-800
background-color: #9A3412;
bg-orange-900
background-color: #7C2D12;
bg-orange-950
background-color: #431407;
bg-amber-50
background-color: #FFFBEB;
bg-amber-100
background-color: #FEF3C7;
bg-amber-200
background-color: #FDE68A;
bg-amber-300
background-color: #FCD34D;
bg-amber-400
background-color: #FBBF24;
bg-amber-500
background-color: #F59E0B;
bg-amber-600
background-color: #D97706;
bg-amber-700
background-color: #B45309;
bg-amber-800
background-color: #92400E;
bg-amber-900
background-color: #78350F;
bg-amber-950
background-color: #451A03;
bg-yellow-50
background-color: #FEFCE8;
bg-yellow-100
background-color: #FEF9C3;
bg-yellow-200
background-color: #FEF08A;
bg-yellow-300
background-color: #FDE047;
bg-yellow-400
background-color: #FACC15;
bg-yellow-500
background-color: #EAB308;
bg-yellow-600
background-color: #CA8A04;
bg-yellow-700
background-color: #A16207;
bg-yellow-800
background-color: #854D0E;
bg-yellow-900
background-color: #713F12;
bg-yellow-950
background-color: #422006;
bg-lime-50
background-color: #F7FEE7;
bg-lime-100
background-color: #ECFCCB;
bg-lime-200
background-color: #D9F99D;
bg-lime-300
background-color: #BEF264;
bg-lime-400
background-color: #A3E635;
bg-lime-500
background-color: #84CC16;
bg-lime-600
background-color: #65A30D;
bg-lime-700
background-color: #4D7C0F;
bg-lime-800
background-color: #3F6212;
bg-lime-900
background-color: #365314;
bg-lime-950
background-color: #1A2E05;
bg-green-50
background-color: #F0FDF4;
bg-green-100
background-color: #DCFCE7;
bg-green-200
background-color: #BBF7D0;
bg-green-300
background-color: #86EFAC;
bg-green-400
background-color: #4ADE80;
bg-green-500
background-color: #22C55E;
bg-green-600
background-color: #16A34A;
bg-green-700
background-color: #15803D;
bg-green-800
background-color: #166534;
bg-green-900
background-color: #14532D;
bg-green-950
background-color: #052E16;
bg-emerald-50
background-color: #ECFDF5;
bg-emerald-100
background-color: #D1FAE5;
bg-emerald-200
background-color: #A7F3D0;
bg-emerald-300
background-color: #6EE7B7;
bg-emerald-400
background-color: #34D399;
bg-emerald-500
background-color: #10B981;
bg-emerald-600
background-color: #059669;
bg-emerald-700
background-color: #047857;
bg-emerald-800
background-color: #065F46;
bg-emerald-900
background-color: #064E3B;
bg-emerald-950
background-color: #022C22;
bg-teal-50
background-color: #F0FDFA;
bg-teal-100
background-color: #CCFBF1;
bg-teal-200
background-color: #99F6E4;
bg-teal-300
background-color: #5EEAD4;
bg-teal-400
background-color: #2DD4BF;
bg-teal-500
background-color: #14B8A6;
bg-teal-600
background-color: #0D9488;
bg-teal-700
background-color: #0F766E;
bg-teal-800
background-color: #115E59;
bg-teal-900
background-color: #134E4A;
bg-teal-950
background-color: #042F2E;
bg-cyan-50
background-color: #ECFEFF;
bg-cyan-100
background-color: #CFFAFE;
bg-cyan-200
background-color: #A5F3FC;
bg-cyan-300
background-color: #67E8F9;
bg-cyan-400
background-color: #22D3EE;
bg-cyan-500
background-color: #06B6D4;
bg-cyan-600
background-color: #0891B2;
bg-cyan-700
background-color: #0E7490;
bg-cyan-800
background-color: #155E75;
bg-cyan-900
background-color: #164E63;
bg-cyan-950
background-color: #083344;
bg-sky-50
background-color: #F0F9FF;
bg-sky-100
background-color: #E0F2FE;
bg-sky-200
background-color: #BAE6FD;
bg-sky-300
background-color: #7DD3FC;
bg-sky-400
background-color: #38BDF8;
bg-sky-500
background-color: #0EA5E9;
bg-sky-600
background-color: #0284C7;
bg-sky-700
background-color: #0369A1;
bg-sky-800
background-color: #075985;
bg-sky-900
background-color: #0C4A6E;
bg-sky-950
background-color: #082F49;
bg-blue-50
background-color: #EFF6FF;
bg-blue-100
background-color: #DBEAFE;
bg-blue-200
background-color: #BFDBFE;
bg-blue-300
background-color: #93C5FD;
bg-blue-400
background-color: #60A5FA;
bg-blue-500
background-color: #3B82F6;
bg-blue-600
background-color: #2563EB;
bg-blue-700
background-color: #1D4ED8;
bg-blue-800
background-color: #1E40AF;
bg-blue-900
background-color: #1E3A8A;
bg-blue-950
background-color: #172554;
bg-indigo-50
background-color: #EEF2FF;
bg-indigo-100
background-color: #E0E7FF;
bg-indigo-200
background-color: #C7D2FE;
bg-indigo-300
background-color: #A5B4FC;
bg-indigo-400
background-color: #818CF8;
bg-indigo-500
background-color: #6366F1;
bg-indigo-600
background-color: #4F46E5;
bg-indigo-700
background-color: #4338CA;
bg-indigo-800
background-color: #3730A3;
bg-indigo-900
background-color: #312E81;
bg-indigo-950
background-color: #1E1B4B;
bg-violet-50
background-color: #F5F3FF;
bg-violet-100
background-color: #EDE9FE;
bg-violet-200
background-color: #DDD6FE;
bg-violet-300
background-color: #C4B5FD;
bg-violet-400
background-color: #A78BFA;
bg-violet-500
background-color: #8B5CF6;
bg-violet-600
background-color: #7C3AED;
bg-violet-700
background-color: #6D28D9;
bg-violet-800
background-color: #5B21B6;
bg-violet-900
background-color: #4C1D95;
bg-violet-950
background-color: #2E1065;
bg-purple-50
background-color: #FAF5FF;
bg-purple-100
background-color: #F3E8FF;
bg-purple-200
background-color: #E9D5FF;
bg-purple-300
background-color: #D8B4FE;
bg-purple-400
background-color: #C084FC;
bg-purple-500
background-color: #A855F7;
bg-purple-600
background-color: #9333EA;
bg-purple-700
background-color: #7E22CE;
bg-purple-800
background-color: #6B21A8;
bg-purple-900
background-color: #581C87;
bg-purple-950
background-color: #3B0764;
bg-fuchsia-50
background-color: #FDF4FF;
bg-fuchsia-100
background-color: #FAE8FF;
bg-fuchsia-200
background-color: #F5D0FE;
bg-fuchsia-300
background-color: #F0ABFC;
bg-fuchsia-400
background-color: #E879F9;
bg-fuchsia-500
background-color: #D946EF;
bg-fuchsia-600
background-color: #C026D3;
bg-fuchsia-700
background-color: #A21CAF;
bg-fuchsia-800
background-color: #86198F;
bg-fuchsia-900
background-color: #701A75;
bg-fuchsia-950
background-color: #4A044E;
bg-pink-50
background-color: #FDF2F8;
bg-pink-100
background-color: #FCE7F3;
bg-pink-200
background-color: #FBCFE8;
bg-pink-300
background-color: #F9A8D4;
bg-pink-400
background-color: #F472B6;
bg-pink-500
background-color: #EC4899;
bg-pink-600
background-color: #DB2777;
bg-pink-700
background-color: #BE185D;
bg-pink-800
background-color: #9D174D;
bg-pink-900
background-color: #831843;
bg-pink-950
background-color: #500724;
bg-rose-50
background-color: #FFF1F2;
bg-rose-100
background-color: #FFE4E6;
bg-rose-200
background-color: #FECDD3;
bg-rose-300
background-color: #FDA4AF;
bg-rose-400
background-color: #FB7185;
bg-rose-500
background-color: #F43F5E;
bg-rose-600
background-color: #E11D48;
bg-rose-700
background-color: #BE123C;
bg-rose-800
background-color: #9F1239;
bg-rose-900
background-color: #881337;
bg-rose-950
background-color: #4C0519;

Using Background Color

You can apply background colors to any element to change its look.

Usage in UXML

Background Color in UXML

<ui:VisualElement class="flex flex-row" >
    <ui:Button text="Button 1" class="bg-violet-600 " />
    <ui:Button text="Button 2" class="bg-indigo-800" />
    <ui:Button text="Button 3" class="bg-cyan-500" />
</ui:VisualElement>

Customize

Modifier Variations

Modifier Variations

You can customize which modifier variations of the Background Color utility are generated, such as pseudo-classes (e.g., hover, focus) and custom modifiers.

These modifier variations are enabled for the Background Color utility by default:
  • hover
  • focus
  • checked

By fine-tuning the utility variations, you maintain control over your stylesheet's size and complexity, ensuring that only necessary styles are included. To update these values:

  1. Open the Theme Config Asset: Find the asset within your Unity project.
  2. Navigate to the 'Utilities' Section: Locate the Background Color utility.
  3. Adjust Modifier Variations: Select which modifiers you want to be generated for the utility. Keep in mind that the order of the modifiers will affect the order and specificity of the generated USS classes.

Class Tags and Properties

Class Tags and Properties

The Background Color utility generates classes based on predefined tags and their associated USS properties. While we recommend keeping these defaults for consistency and ease of reference in our documentation, you have the option to customize them to suit your project's specific needs.

These values are prepended to the defined values in this format tag-{value}. If a tag is empty, the generated class will simply be the value by itself.

Here are the default tags and the USS properties they set for the Background Color utility:

  • bg : background-color

To customize these tags and properties, you can edit the Tag Property Map field for the Background Color utility in the Theme Config asset. This allows you to define new tags or modify existing ones, thus tailoring the generated classes to your preferences.

Extending Core Fields

The Background Color utility uses values from the following fields from the Core section of the Theme Config asset:

  • Colors
These fields are used in addition to any custom values defined for the utility. If the same key exists in both the utility and core configurations, the utility's values will override those from the core.

To customize or define these extended fields:

  1. Open the Theme Config Asset: Locate the asset within your Unity project.
  2. Navigate to the 'Utilities' Section: Find the Background Color utility.
  3. Customize Extend Fields: Modify or add fields in the Extend Fields array to change the core configuration values that are extended. You'll only be able to extend fields of the same type.

Disable Utility

The Background Color utility is enabled by default. You can disable it by unchecking the Enabled option in the Theme Config asset. This will prevent the generation of the utility's styles.

Previous
Align Self