Styling & Theming
Full Design Control
Customize every aspect of the widget β from simple presets to 50+ design tokens for complete brand alignment.
Interactive Theme Previewβ
Quick Stylingβ
Preset Themesβ
Choose from four built-in themes:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
theme="dark"
></pollarix-widget>
widget.configure({
customTheme: {
preset: 'dark'
}
});
| Theme | Description |
|---|---|
light | Clean white background, dark text (default) |
dark | Dark background, light text |
minimal | Reduced visual elements, no shadows |
glass | Frosted glass effect with blur |
Accent Colorβ
Change the primary brand color:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
accent-color="#FF5733"
></pollarix-widget>
widget.configure({
style: {
accentColor: '#FF5733'
}
});
The accent color should have at least 3:1 contrast ratio against the background for WCAG compliance.
Style Configurationβ
Rating Shapeβ
Control the button shape:
widget.configure({
style: {
ratingShape: 'pill' // 'rounded' | 'pill' | 'circle' | 'square'
}
});
| Shape | Description |
|---|---|
rounded | Slight rounding (default) |
pill | Fully rounded ends |
circle | Perfect circles |
square | No rounding |
Rating Sizeβ
Control the button size:
widget.configure({
style: {
ratingSize: 'large' // 'compact' | 'comfortable' | 'large'
}
});
| Size | Dimensions |
|---|---|
compact | 32x36px (default) |
comfortable | 40x44px |
large | 48x52px |
Color Schemeβ
Control rating button colors:
widget.configure({
style: {
colorScheme: 'semantic' // 'neutral' | 'brand' | 'semantic'
}
});
| Scheme | Description |
|---|---|
neutral | All buttons same color (default) |
brand | Uses accent color for selected |
semantic | RedβYellowβGreen gradient |
Semantic color scheme may introduce response bias (3-5%). Use for internal surveys only.
Advanced Themingβ
For complete control, use the theme configuration inspired by Stripe Elements.
Theme Structureβ
widget.configure({
customTheme: {
preset: 'light', // Start with a preset
variables: { ... }, // Override design tokens
rules: { ... }, // Component-specific CSS
}
});
Theme Variables (Design Tokens)β
Override any of 50+ design tokens:
widget.configure({
customTheme: {
preset: 'light',
variables: {
// Colors
colorPrimary: '#6366F1',
colorPrimaryHover: '#4F46E5',
colorBackground: '#FFFFFF',
colorText: '#111827',
colorTextSecondary: '#6B7280',
colorBorder: '#E5E7EB',
// Typography
fontFamily: "'Inter', sans-serif",
fontSizeBase: '15px',
fontWeightMedium: 500,
// Spacing & Borders
borderRadius: '12px',
spacingPadding: '24px',
// Shadows
shadowContainer: '0 8px 24px rgba(0, 0, 0, 0.12)',
}
}
});
All Variable Categoriesβ
Color Variables (18 tokens)
| Variable | Description |
|---|---|
colorPrimary | Primary accent color |
colorPrimaryHover | Hover state of primary |
colorPrimaryLight | Light tint of primary |
colorPrimaryText | Text on primary background |
colorBackground | Main background |
colorBackgroundSecondary | Secondary surface |
colorBackgroundHover | Hover state background |
colorText | Primary text |
colorTextSecondary | Secondary text |
colorTextMuted | Disabled/placeholder text |
colorBorder | Default border |
colorBorderHover | Border on hover |
colorBorderFocus | Border on focus |
colorSuccess | Success state |
colorSuccessBackground | Success background |
colorError | Error state |
colorErrorBackground | Error background |
colorWarning | Warning state |
Typography Variables (10 tokens)
| Variable | Default |
|---|---|
fontFamily | Inter, system fonts |
fontFamilyMono | SF Mono, Fira Code |
fontSizeBase | 15px |
fontSizeSmall | 14px |
fontSizeLarge | 17px |
fontSizeXs | 12px |
fontWeightNormal | 400 |
fontWeightMedium | 500 |
fontWeightSemibold | 600 |
fontWeightBold | 700 |
Rating Component Variables (11 tokens)
| Variable | Description |
|---|---|
ratingWidth | Button width |
ratingHeight | Button height |
ratingBackground | Default background |
ratingBorderColor | Default border |
ratingTextColor | Default text |
ratingHoverBackground | Hover background |
ratingHoverBorderColor | Hover border |
ratingHoverTextColor | Hover text |
ratingSelectedBackground | Selected background |
ratingSelectedBorderColor | Selected border |
ratingSelectedTextColor | Selected text |
Button Variables (6 tokens)
| Variable | Description |
|---|---|
buttonHeight | Button height |
buttonBackground | Default background |
buttonTextColor | Text color |
buttonHoverBackground | Hover background |
buttonDisabledBackground | Disabled background |
buttonDisabledTextColor | Disabled text |
Theme Rulesβ
For component-specific overrides, use CSS rules:
widget.configure({
customTheme: {
preset: 'dark',
rules: {
'.submit-button': {
borderRadius: '999px',
fontWeight: 600,
},
'.submit-button:hover': {
transform: 'scale(1.02)',
},
'.rating-item': {
borderWidth: '2px',
},
'.widget-container': {
backdropFilter: 'blur(10px)',
},
}
}
});
Available Selectorsβ
| Selector | Target |
|---|---|
.widget-container | Main container |
.widget-header | Header area |
.widget-title | Question title |
.close-button | Close button |
.rating-scale | Rating buttons container |
.rating-item | Individual rating button |
.rating-item:hover | Rating hover state |
.rating-item[data-selected="true"] | Selected rating |
.legend | Scale labels |
.submit-button | Submit button |
.comment-textarea | Feedback input |
.success-view | Thank you screen |
.powered-by | Footer |
HTML Theme Attributesβ
Quick theme customization via attributes:
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
theme-preset="dark"
theme-primary="#6366F1"
theme-background="#1A1B26"
theme-text="#F3F4F6"
theme-font-family="'Inter', sans-serif"
theme-border-radius="12px"
></pollarix-widget>
Dark Mode Supportβ
The widget respects system dark mode when using the dark theme:
// Automatically use dark theme for dark mode users
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
widget.configure({
customTheme: {
preset: prefersDark ? 'dark' : 'light'
}
});
Accessibilityβ
The widget validates themes for WCAG compliance:
widget.configure({
customTheme: {
variables: {
colorText: '#CCCCCC',
colorBackground: '#FFFFFF',
}
}
});
// Console warning: "Text contrast 1.6:1 fails WCAG AA (needs 4.5:1)"
Contrast Requirementsβ
| Element | Minimum Ratio |
|---|---|
| Body text | 4.5:1 (AA) |
| Large text | 3:1 (AA) |
| UI components | 3:1 (AA) |
Complete Theme Exampleβ
widget.configure({
customTheme: {
preset: 'light',
variables: {
// Brand colors
colorPrimary: '#2563EB',
colorPrimaryHover: '#1D4ED8',
colorPrimaryLight: '#EFF6FF',
// Typography
fontFamily: "'Poppins', sans-serif",
fontSizeBase: '16px',
// Rounded design
borderRadius: '16px',
borderRadiusSmall: '12px',
// Soft shadows
shadowContainer: '0 20px 40px rgba(0, 0, 0, 0.1)',
// Rating buttons
ratingSelectedBackground: '#2563EB',
ratingSelectedTextColor: '#FFFFFF',
},
rules: {
'.submit-button': {
borderRadius: '999px',
padding: '12px 32px',
},
'.widget-container': {
border: '1px solid #E5E7EB',
},
}
}
});
Next Stepsβ
- Events & API - JavaScript API reference
- Examples - Complete theme examples