Skip to main content
MCP Apps SDK
In React components, useHostStyles applies CSS variables, theme, and fonts automatically. The function below is useful for non-React usage or custom control.

Overview

Hosts provide CSS custom properties for colors, typography, borders, and more via McpUiHostContext.styles.variables. Use applyHostStyleVariables to set these on the document, then reference them in your CSS with var().

applyHostStyleVariables

Sets each CSS variable from the host as a custom property on the specified element.

Signature

styles
McpUiStyles
required
Style variables object from McpUiHostContext.styles.variables.
root
HTMLElement
default:"document.documentElement"
Element to apply styles to.

Usage

Then use the variables in CSS:

Available Variables

All variables are optional — hosts may provide any subset.

Background Colors

Text Colors

Border Colors

Ring Colors

Typography

Border Radius

Other

See also: Theme for light/dark mode detection, and Fonts for host typography.
The sunpeak framework provides useHostContext which auto-applies host styles in React components.