Import
Functions
css()
Defines scoped CSS styles and returns a unique class name.TemplateStringsArray
required
The CSS template string
CssVariableType[]
required
Values to interpolate into the CSS (variables, other css() results, etc.)
Promise<string>
A unique class name for the scoped styles
cx()
Combines multiple class names, similar to the popularclassnames library.
(CssClassName | Promise<string> | string | boolean | null | undefined)[]
required
Class names to combine. Falsy values are ignored.
Promise<string>
Combined class names as a single string
keyframes()
Defines CSS keyframe animations.TemplateStringsArray
required
The keyframes template string
CssVariableType[]
required
Values to interpolate
CssClassNameCommon
A keyframes name that can be used in CSS animations
Style()
Renders the<style> tag containing all accumulated CSS.
Promise<string>
Optional CSS content to include in the style tag
string
Optional nonce attribute for Content Security Policy
HtmlEscapedString
A style tag containing all CSS styles used in the current render
viewTransition()
Creates styles for view transitions API.TemplateStringsArray
The CSS template for view transition
CssVariableType[]
Values to interpolate
Promise<string>
A view transition name
createCssContext()
Creates an isolated CSS context with a custom style ID.string
required
A unique identifier for the style tag
object
An object containing isolated versions of
css, cx, keyframes, viewTransition, and StyleFeatures
Automatic Scoping
All styles defined withcss() are automatically scoped with unique class names, preventing style conflicts:
Nesting Support
Supports CSS nesting for pseudo-classes and nested selectors:CSS Variables
Interpolate values and other styles:Performance Considerations
- Styles are generated on-demand during rendering
- Duplicate styles are automatically deduplicated
- The Style component must be included in the
<head>for styles to render