Class ContextProvider
A container component that provides contextual settings to its children in the UI hierarchy.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class ContextProvider : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
The ContextProvider is a powerful layout component that allows you to override various UI settings for a specific section of your interface. It acts as a wrapper around UI elements, providing contextual configurations that affect all child elements within its scope.
This component is particularly useful when you need to create isolated sections of your UI with different themes, scales, languages, or layout directions without affecting the rest of the application.
Note: The ContextProvider's picking mode is set to ignore by default, meaning it won't intercept any pointer events. This allows events to pass through to its children.
Examples
Here are some common usage examples of the ContextProvider component. Creating a dark-themed modal dialog:
<ContextProvider theme="dark" scale="medium">
<Dialog>
<Header text="Dark Theme Dialog" />
<Content>
<Label text="This entire dialog uses dark theme styling" />
</Content>
<Footer>
<Button text="Close" />
</Footer>
</Dialog>
</ContextProvider>
Setting up a multilingual section with RTL support.
<ContextProvider lang="ar-SA" dir="Rtl">
<Panel class="form-section">
<TextField label="الاسم" />
<TextField label="البريد الإلكتروني" />
<Button text="إرسال" />
</Panel>
</ContextProvider>
Creating a larger scale section for improved accessibility.
<ContextProvider scale="large" tooltip-delay-ms="0">
<Panel class="accessibility-section">
<Label text="Larger Text for Better Visibility" />
<Button text="Easy to Click" tooltip="Instant tooltip" />
</Panel>
</ContextProvider>
Constructors
ContextProvider()
Default constructor.
Declaration
public ContextProvider()
Fields
ussClassName
Main Uss Class Name.
Declaration
public const string ussClassName = "appui-context-provider"
Field Value
| Type | Description |
|---|---|
| string |