create_component_theme
Generate Sass or CSS code to customize an Ignite UI component's appearance using design tokens.
<use_case> Use this tool AFTER calling get_component_design_tokens to customize specific component styles. The generated code can be included in your theme file to override default component appearances. </use_case>
<workflow>
- First call get_component_design_tokens to discover available tokens
- Choose which tokens to customize based on your design requirements
- Specify designSystem and variant to match the global theme or the one explicitly requested (defaults to Material light)
- Call this tool with component name, token values, and output format ("sass" or "css")
- Receive ready-to-use Sass or CSS code with the component theme
</workflow>
<important_notes> DESIGN SYSTEM & VARIANT:
- designSystem: Choose "material" (default), "bootstrap", "fluent", or "indigo"
- variant: Choose "light" (default) or "dark"
- The correct schema (e.g., $light-bootstrap-schema, $dark-material-schema) is automatically selected and passed to the component theme function
- The correct output: Choose output format based on the target file type (Sass vs CSS)
- This ensures component tokens inherit proper defaults from the design system
TOKEN VALIDATION:
- All provided token names are validated against the component's schema
- Invalid tokens return an error with the list of valid token names
- You don't need to specify all tokens - only those you want to customize (prefer PRIMARY tokens to minimize the number of overrides)
TOKEN VALUE FORMATS:
- Colors: Any valid CSS color format (hex, rgb, hsl, named colors)
- Dimensions: Include units (e.g., "8px", "0.5rem", "2em")
- Border radius: Can be single value or shorthand ("8px" or "8px 8px 0 0")
- Shadows: Full box-shadow syntax ("0 2px 4px rgba(0,0,0,0.1)")
SELECTORS:
- Default selector is auto-detected based on platform and component
- For child sub-components (e.g., "list-item", "card-header"), the selector automatically resolves to the parent component's selector (e.g., "igx-list", "igx-card")
- Angular: Uses "igx-*" element selectors or attribute selectors
- Web Components: Uses "igc-*" element selectors
- Custom selectors supported for targeted styling (e.g., ".my-button")
CHILD SUB-COMPONENTS:
- When creating a theme for a child sub-component (e.g., "card-actions"), the output uses the parent's theme function, variable name, and selector.
- This means the output for "card" and "card-actions" is merge-compatible: both produce
$custom-card-theme: card-theme(...)scoped toigx-card. - To add tokens for multiple sub-parts, merge the token arguments into a single theme function call rather than creating separate themes.
SASS OUTPUT:
- Generated code uses
@include tokens($theme)to apply the theme - The tokens mixin emits --ig-{component}-{token} CSS custom properties in global mode
COMPOUND COMPLETENESS:
- Standard compounds: If the user asks for a standard compound component, the response is incomplete unless related theme calls are also generated. Use the related themes list from get_component_design_tokens to drive the sequence. All related themes should use the compound component's selector as the wrapper. Follow token derivation hints to set child token values consistently.
- Composed compounds: If the component is a composed compound (e.g., grid), do NOT generate separate child themes. Only set the primary tokens (background, foreground, accent-color) on the parent component's theme — child themes are auto-derived internally by the component's Sass styles. Refinement tokens (e.g., header-background) can be added in follow-up calls when the user explicitly asks to customize a specific aspect.
SASS FILE PLACEMENT:
- When combining Sass output from multiple tools into one file, all @use rules must appear at the top before any other statements. Deduplicate @use lines that share the same module path.
</important_notes>
<output> Returns:
- Generated Sass or CSS code with:
- Platform-specific @use import (Sass only)
- Theme function call with $schema parameter and provided token values (Sass only)
- tokens mixin to apply the theme to the selector (Sass only)
- Description of what was generated
- Design system and variant used
- List of tokens used
</output>
<error_handling>
- Unknown component: Returns error with list of available components
- Invalid tokens: Returns error listing invalid tokens and valid alternatives
- Invalid color format: Returns error with format guidance
</error_handling>
<example> Custom blue flat button with rounded corners (Angular, Material Design): { "platform": "angular", "designSystem": "material", "variant": "light", "component": "flat-button", "tokens": { "foreground": "#1976d2", } }
Generates:
@use 'igniteui-angular/theming' as *;
$custom-flat-button-theme: flat-button-theme(
$schema: $light-material-schema,
$foreground: #1976d2,
);
.igx-button--flat {
@include tokens($custom-flat-button-theme);
}Bootstrap dark theme example: { "platform": "webcomponents", "designSystem": "bootstrap", "variant": "dark", "component": "avatar", "tokens": { "background": "#ff5722" } }
Generates:
@use 'igniteui-theming' as *;
$custom-avatar-theme: avatar-theme(
$schema: $dark-bootstrap-schema,
$background: #ff5722
);
igc-avatar {
@include tokens($custom-avatar-theme);
}</example>
<compound_example> Date Picker (compound) — all child themes use the parent component's selector. Follow token derivation hints from get_component_design_tokens:
- get_component_design_tokens { "component": "date-picker" }
- create_component_theme { "component": "date-picker", "platform": "angular", ... }
- create_component_theme { "component": "calendar", "selector": "igx-date-picker", ... }
- create_component_theme { "component": "flat-button", "selector": "igx-date-picker", ... }
- create_component_theme { "component": "input-group", "selector": "igx-date-picker", ... }
Each child theme uses the parent's platform selector (e.g., igx-date-picker for Angular, igc-date-picker for Web Components / React / Blazor). The tokens mixin emits --ig-{component}-{token} variables that child components consume via var() fallback — no per-child selectors needed. </compound_example>
<related_tools>
- detect_platform: Run to auto-detect platform for correct imports
- get_component_design_tokens: MUST call first to discover valid tokens
- create_theme: Use for full theme (palette + typography + elevations)
</related_tools>