TaoProvider
@rockshin/tao-uiProvides global component defaults, portal scoping, and theme seed token overrides.
When to use
Wrap an app or subtree with TaoProvider to set size, disabled, variant, and theme defaults.
Recommended
- Prefer provider-level defaults for app-wide decisions.
- Use nested providers for scoped theme overrides.
Avoid
- Do not override derived CSS variables directly unless a theme token cannot express the change.
Examples
Basic usage
Global sizes
Brand tokens and component tokens
Dark mode, compact density, and isolation
Global variants
Set a common appearance for form controls and override individual controls when needed.
Brand colors
Change brand colors across the same components while retaining status semantics.
Semantic colors
Configure success, warning, and error colors separately so states remain distinguishable.
ring color follows colorError token
Radius scale
The base radius derives size-specific radii; compare the effect across controls.
Nesting and isolation
Nested providers can inherit or reset their theme without affecting the outer scope.
Portal theme inheritance
Open the dropdown to see that portal content retains its provider theme.
Dynamic theme switching
Change theme settings through state and observe the controls and popups update.
Layout transparency
The provider does not add a layout wrapper, so components retain their parent layout.
Component tokens
Override tokens for a target component while other components retain the global theme.
Compact density
Compact mode changes spacing and control density while retaining the theme font size.
Right-to-left layouts
Set direction="rtl" on TaoProvider or use HTML dir="rtl" on a surrounding element. Components inherit the local direction, and popups keep the direction of their trigger even when rendered into a portal. An explicit component direction prop or nested provider can override it; Carousel uses rtl. Locale and direction are independent. Explicit popup placements such as bottomLeft retain their physical meaning.
17 languages and regional formats
Switch the language to update component defaults, dates and numbers. Existing ISO date formats remain the default; this example explicitly requests a regional date with format="L". Numeric input still emits canonical ASCII decimal strings. Caller-owned labels are independent of the component dictionary.
API
useTaoInternalConfig
Internal component access for token propagation through third-party portals.
useTaoDirection
Resolve DOM inheritance at a component's source, before it creates portals.
useTaoToken
**antd theme.useToken counterpart, zero-runtime edition: returns every
design token as a var(--tao-*) reference string, so custom components can
stay visually consistent with tao-ui and still resolve in the browser
against the live theme (dark mode, seed overrides, compact density):