CSS and theme utilities for Gradio UI components, providing styling, color palettes, typography, and reset styles.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Gradio Theme provides essential CSS and JavaScript utilities for theming Gradio UI components. It offers a comprehensive color system with predefined palettes, CSS reset styles, global styling rules, typography definitions, and theme tokens for building consistent Gradio web interfaces.
npm install @gradio/themeJavaScript/TypeScript color utilities:
import { colors, ordered_colors, color_values } from "@gradio/theme";CSS imports for styling:
@import "@gradio/theme/reset.css";
@import "@gradio/theme/global.css";
@import "@gradio/theme/typography.css";
@import "@gradio/theme/pollen.css";Individual token imports:
import "@gradio/theme/tokens";import { colors, ordered_colors } from "@gradio/theme";
import "@gradio/theme/reset.css";
import "@gradio/theme/global.css";
// Use predefined theme colors
const primaryBlue = colors.blue.primary; // "#2563eb"
const secondaryBlue = colors.blue.secondary; // "#dbeafe"
// Iterate through available colors
ordered_colors.forEach(colorName => {
console.log(`${colorName}: ${colors[colorName].primary}`);
});
// Access color configuration
console.log(color_values); // Array of color configurationsGradio Theme is built around several key components:
Provides programmatic access to a consistent color palette with primary and secondary variants for each theme color.
/**
* Ordered array of available theme color names
*/
const ordered_colors: readonly [
"red", "green", "blue", "yellow", "purple",
"teal", "orange", "cyan", "lime", "pink"
];
/**
* Color configuration array with primary/secondary tone mappings
*/
const color_values: readonly {
color: string;
primary: number;
secondary: number;
}[];
/**
* Main color palette object with computed hex values
*/
const colors: Colors;
interface ColorPair {
primary: string;
secondary: string;
}
interface Colors {
red: ColorPair;
green: ColorPair;
blue: ColorPair;
yellow: ColorPair;
purple: ColorPair;
teal: ColorPair;
orange: ColorPair;
cyan: ColorPair;
lime: ColorPair;
pink: ColorPair;
}Usage Examples:
import { colors, ordered_colors, color_values } from "@gradio/theme";
// Get specific color values
const redPrimary = colors.red.primary; // "#dc2626"
const redSecondary = colors.red.secondary; // "#fee2e2"
// Iterate through all colors
ordered_colors.forEach(colorName => {
const colorPair = colors[colorName];
console.log(`${colorName}: ${colorPair.primary}, ${colorPair.secondary}`);
});
// Access configuration metadata
const blueConfig = color_values.find(c => c.color === "blue");
// { color: "blue", primary: 600, secondary: 100 }Provides CSS reset and normalization styles for consistent cross-browser rendering.
Import:
@import "@gradio/theme/reset.css";Key Features:
.gradio-container and all elements (box-sizing: border-box)Provides global utility classes and component-specific styles for Gradio applications.
Import:
@import "@gradio/theme/global.css";Key Utility Classes:
.scroll-hide - Hides scrollbars across browsers.sr-only - Screen reader only content (visually hidden).gradio-container - Base container styling.cropper-container - Image cropper component stylingCustom Element Support:
gradio-lite element styling with FOUC preventiongradio-lite elementsProvides comprehensive typography styling with CSS custom properties for flexible theming.
Import:
@import "@gradio/theme/typography.css";Key Classes:
.prose - Main typography class for content areas--prose-text-weight--prose-header-text-weight--body-text-color--text-* size variables--spacing-* variablesProvides responsive breakpoint definitions as CSS custom media queries.
Import:
import "@gradio/theme/tokens";Available Breakpoints:
@custom-media --screen-sm (min-width: 640px);
@custom-media --screen-md (min-width: 768px);
@custom-media --screen-lg (min-width: 1024px);
@custom-media --screen-xl (min-width: 1280px);
@custom-media --screen-xxl (min-width: 1536px);
@custom-media --screen-xxxl (min-width: 1920px);Provides generated CSS from Pollen configuration with custom design tokens including colors, typography, spacing, and border radius values.
Import:
@import "@gradio/theme/pollen.css";Generated from Pollen configuration including:
Key Design Tokens Available:
--font-sans, --font-mono--radius-xs through --radius-3xl--size-* variables including fractional sizesThe package includes a Pollen CSS configuration file that generates the design system CSS. This configuration extends the default Pollen modules with Gradio-specific customizations:
Key Configuration Areas:
The configuration outputs to src/pollen.css and provides CSS custom properties for all design tokens.