n-element

Expose Naive UI theme CSS variables inside custom elements.

8|3|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/jiaiyan/naive-ui-skills --skill n-element
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n-element
Source: https://github.com/jiaiyan/naive-ui-skills/tree/main/components/n-element
Command: npx skills add https://github.com/jiaiyan/naive-ui-skills --skill n-element

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Element provides access to Naive UI's theme CSS variables for use in custom elements and to read CSS variables within the theme context.

Core Features & Use Cases

  • CSS Variable Access: Read and apply all theme CSS variables to achieve consistent styling across custom components.
  • Custom Tag: Render as any HTML tag for flexible integration.
  • Theme Reactive: Updates automatically when the theme changes.
  • No Extra Styling: Lightweight pass-through to preserve design.

Quick Start

Wrap your content with n-config-provider to expose theme variables and apply them using CSS variables.

Frequently Asked Questions about n-element

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I apply Naive UI theme variables to custom HTML elements?

You can apply Naive UI theme variables to custom elements by wrapping your content with n-config-provider to expose the theme context, then accessing the CSS variables to style your custom components for consistent theme adaptation.

Can I use the useThemeVars helper to read CSS variables in Vue components?

Yes, you can use the useThemeVars helper to read Naive UI theme values inside Vue custom elements. This allows your components to access and apply the CSS variables dynamically while maintaining reactivity when the theme changes.

What is the best way to make custom Vue components reactive to Naive UI theme changes?

To make custom Vue components reactive to Naive UI theme changes, use the n-element approach to access theme CSS variables. Updates apply automatically when the theme switches, ensuring your custom widgets adapt without manual style overrides.

Do I need n-config-provider to pass theme context to custom elements?

Yes, n-config-provider is required to establish the theme context. You must wrap your custom elements with it to expose the Naive UI theme CSS variables, enabling your custom components to read and apply the current theme values accurately.

Does applying Naive UI CSS variables to custom elements add extra styling?

No, applying Naive UI CSS variables to custom elements does not add extra styling. It acts as a lightweight pass-through to preserve your existing design while providing theme-aware variable access, ensuring no unwanted CSS overrides are injected.