syncfusion/blazor-ui-components-skills / skills/syncfusion-blazor-query-builder
syncfusion-blazor-query-builder
VerifiedImplement Syncfusion Blazor Query Builder component for building dynamic, customizable query interfaces with complex filtering logic. Use this when creating advanced search interfaces, implementing business rule engines, or building data filtering workflows with nested condition groups and AND/OR logic. Supports rule management, drag-drop UI, state persistence, and extensive customization options.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 16.5 KB |
| references/advanced-features.md | markdown | 17.7 KB |
| references/basic-setup.md | markdown | 7.7 KB |
| references/customization-and-styling.md | markdown | 7.5 KB |
| references/data-binding.md | markdown | 9.8 KB |
| references/events-and-callbacks.md | markdown | 10.5 KB |
| references/filtering-and-rules.md | markdown | 10.3 KB |
| references/getting-started.md | markdown | 5.0 KB |
| references/localization-and-accessibility.md | markdown | 6.4 KB |
| references/troubleshooting.md | markdown | 9.4 KB |
references/localization-and-accessibility.md
View on GitHub# Localization & Accessibility
This guide covers multi-language support, RTL (Right-to-Left) support, and accessibility best practices for the Query Builder component.
## Localization
### Configure Locale
Set the locale in your Blazor application:
```csharp
// In Program.cs
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSyncfusionBlazor();
builder.Services.Configure<SyncfusionBlazorSettings>(options =>
{
options.Locale = "fr-FR"; // Set to French
});
var app = builder.Build();
```
### Supported Locales
Query Builder supports multiple locales:
- `en-US` - English (United States, default)
- `fr-FR` - French
- `de-DE` - German
- `es-ES` - Spanish
- `ja-JP` - Japanese
- `zh-CN` - Chinese (Simplified)
- `zh-TW` - Chinese (Traditional)
- `ar-AR` - Arabic
- `ru-RU` - Russian
- And many more...
### Custom Localization
Define custom translated strings:
```csharp
// In Program.cs
var localization = new SfLocalization();
localization.SetLocale(new Dictionary<string, object>
{
{ "en-US", new Dictionary<string, string>
{
{ "AddRule", "Add Rule" },
{ "AddGroup", "Add Group" },
{ "DeleteGroup", "Delete Group" }
}},
{ "es-ES", new Dictionary<string, string>
{
{ "AddRule", "Agregar Regla" },
{ "AddGroup", "Agregar Grupo" },
{ "DeleteGroup", "Eliminar Grupo" }
}}
});
```
## Right-to-Left (RTL) Support
### Enable RTL Mode
```razor
<SfQueryBuilder TValue="Order" EnableRtl="true">
<QueryBuilderColumns>
<QueryBuilderColumn Field="OrderID" Label="معرّف الطلب" Type="ColumnType.Number"></QueryBuilderColumn>
<QueryBuilderColumn Field="Status" Label="الحالة" Type="ColumnType.String"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
```
### RTL with Locale
```razor
<SfQueryBuilder TValue="Order" EnableRtl="true">
<QueryBuilderColumns>
<QueryBuilderColumn Field="OrderID" Label="معرّف الطلب" Type="ColumnType.Number"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
```
### RTL CSS
```css
/* Automatic RTL adjustments for Arabic/Hebrew */
[dir="rtl"] .e-querybuilder {
direction: rtl;
text-align: right;
}
[dir="rtl"] .e-rule {
text-align: right;
padding-right: 15px;
padding-left: 5px;
}
[dir="rtl"] .e-querybuilder button {
margin-left: auto;
margin-right: 0;
}
```
## Accessibility Best Practices
### WCAG Compliance
Query Builder follows WCAG 2.1 Level AA accessibility standards:
- Keyboard navigation
- Screen reader support
- Color contrast requirements
- Focus indicators
- ARIA labels
### Keyboard Navigation
Enable full keyboard navigation:
```razor
<SfQueryBuilder TValue="Order">
<QueryBuilderColumns>
<QueryBuilderColumn Field="OrderID" Label="Order ID" Type="ColumnType.Number"></QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
<!-- Navigation keys:
Tab - Move to next element
Shift+Tab - Move to previous element
Enter - Activate button or open dropdown
Space - Activate button
Escape - Close dropdown
Arrow keys - Select options in dropdown
-->
```
### ARIA Attributes
Query Builder automatically provides ARIA attributes:
```html
<!-- Generated ARIA attributes -->
<div class="e-querybuilder" role="region" aria-label="Query Builder">
<div class="e-rule" role="group" aria-label="Rule">
<select aria-label="Select Field">
<!-- options -->
</select>
</div>
</div>
```
### Color Contrast
Ensure sufficient contrast for readability:
```css
/* High contrast colors for accessibility */
.e-querybuilder {
color: #212529; /* Dark gray on light background */
background-color: #ffffff;
}
.e-querybuilder .e-rule {
border: 2px solid #495057; /* Visible border */
background-color: #ffffff;
}
/* Focus indicators */
.e-querybuilder input:focus,
.e-querybuilder select:focus,
.e-querybuilder button:focus {
outline: 3px solid #0d6efd; /* Blue outline */
outline-offset: 2px;
}
```
### Screen Reader Support
Make Query Builder screen-reader friendly:
```razor
<SfQueryBuilder TValue="Order" AccessibilityLabel="Filter Orders by Conditions">
<QueryBuilderColumns>
<!-- Provide descriptive labels -->
<QueryBuilderColumn
Field="OrderID"
Label="Order ID"
Type="ColumnType.Number"
AriaLabel="Select Order ID to filter">
</QueryBuilderColumn>
</QueryBuilderColumns>
</SfQueryBuilder>
```
### Label All Fields
```razor
<!-- ✓ Good: Clear labels -->
<label for="query-field">
<span>Filter Field</span>
<select id="query-field" aria-label="Select field to filter">
<!-- options -->
</select>
</label>
<!-- ✗ Bad: Missing labels -->
<select>
<!-- options -->
</select>
```
### Error Messages for Accessibility
```razor
@code {
private string ErrorMessage = "";
private async Task ValidateQuery() {
try {
var rules = QueryBuilder.GetRules();
if (rules == null || rules.Rules.Count == 0) {
ErrorMessage = "Error: Please add at least one condition";
// Announce to screen readers
await JS.InvokeVoidAsync("announce", ErrorMessage);
}
} catch (Exception ex) {
ErrorMessage = $"Error: {ex.Message}";
await JS.InvokeVoidAsync("announce", ErrorMessage);
}
}
}
```
## Accessibility Checklist
- [ ] Keyboard navigation works for all controls
- [ ] Focus indicators are visible
- [ ] Color contrast meets WCAG AA standards (4.5:1 for text)
- [ ] All inputs have associated labels
- [ ] Error messages are clear and associated with fields
- [ ] Screen readers announce all important information
- [ ] Component works with browser zoom (up to 200%)
- [ ] No content relies solely on color
- [ ] Animations can be disabled (prefers-reduced-motion)
## Reduced Motion Support
Respect user's motion preferences:
```css
/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
.e-querybuilder * {
animation: none !important;
transition: none !important;
}
}
```
## Next Steps
- [Advanced Features](advanced-features.md) - Import/export and persistence
- [Troubleshooting](troubleshooting.md) - Accessibility issues
- [Customization](customization-and-styling.md) - Styling accessibility
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |