Registry / web-framework / vue-styled-components

vue-styled-components

JSON →
library1.6.0jsnpmunverified

Vue Styled Components is a port of the popular `styled-components` library, adapting its CSS-in-JS approach to Vue 2.x applications. It allows developers to write actual CSS within JavaScript using tagged template literals, creating Vue components that encapsulate their own styles. The current stable version is 1.6.0. This library differentiates itself by providing a low-level styling construct where components serve as visual primitives, reducing the mapping between components and their stylesheets. However, it is explicitly compatible only with Vue 2.x and is noted as "not fully-featured" compared to the original `styled-components` project. Given its last update was several years ago and its strict Vue 2.x compatibility, it is considered largely unmaintained for modern Vue 3+ development.

npm install vue-styled-components
INSTALL
IMPORT
SIG · VUE-STYLED-COMPONE
V
vue-styled-components
web-frameworkjavascriptv1.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

styled
import styled from 'vue-styled-components';
import { styled } from 'vue-styled-components';
The `styled` factory function is the default export of the package.

Demonstrates creating and rendering basic styled Vue 2 components with static styles.

import Vue from 'vue'; import styled from 'vue-styled-components'; // Create a <StyledTitle> Vue component that renders an <h1> const StyledTitle = styled.h1` font-size: 1.5em; text-align: center; color: palevioletred; `; // Create a <Wrapper> Vue component that renders a <section> const Wrapper = styled.section` padding: 4em; background: papayawhip; `; const app = new Vue({ el: '#app', components: { 'styled-title': StyledTitle, 'wrapper': Wrapper }, template: ` <wrapper> <styled-title>Hello World, this is my first styled component!</styled-title> <p>This paragraph is outside styled components.</p> </wrapper> ` });
Debug
Known issues
breakingThis library is explicitly compatible only with Vue 2.x. It does not support Vue 3 or newer versions, making it unsuitable for modern Vue projects.
fix
For Vue 3 projects, consider alternatives like 'Vue use style' or other CSS-in-JS solutions specifically designed for Vue 3, or use traditional CSS/SCSS with Vue's SFC styling.
affects: >=1.0.0
gotchaThis is noted as a 'not fully-featured' fork of the original `styled-components` library. Some advanced features or newer syntax from the React version might not be implemented or behave differently.
fix
Always refer to the `vue-styled-components` documentation for supported features and examples, rather than relying solely on `styled-components` (React) documentation.
affects: >=1.0.0
gotchaAvoid using built-in or reserved HTML elements (e.g., `title`, `button`, `input`) as component IDs or names for styled components, as this can lead to conflicts and unexpected behavior in Vue.
fix
Prefix your styled component names (e.g., `StyledButton`, `MyTitleComponent`) or use different naming conventions to avoid collisions with native HTML elements.
affects: >=1.0.0
gotchaWhen adapting styles based on props, you must explicitly declare the props using Vue's `props` option for the styled component. Failing to do so will prevent props from being reactive or validated correctly.
fix
Define the expected props for your styled component using the second argument to `styled()`, e.g., `const btnProps = { primary: Boolean }; const StyledButton = styled('button', btnProps)`.
affects: >=1.0.0
Errors
Common errors & fixes
Failed to mount component: template or render function not defined. (found in <Root>)
The Vue instance is missing a `template` or `render` function to display the styled components.
fix
Ensure your Vue instance has a `template` option or a `render` function that includes your styled components, along with their local registration in the `components` option.
[Vue warn]: Unknown custom element: <styled-component-name> - did you register the component correctly?
Vue cannot find the definition for the styled component. This usually means it hasn't been locally registered in the parent component's `components` option.
fix
Add the styled component to the `components` object of the Vue instance or parent component where it is being used, e.g., `components: { 'styled-title': StyledTitle }`.
Property or method "myProp" is not defined on the instance but referenced during render.
You are trying to use a prop in your styled component's template or style function, but it has not been explicitly declared in the component's `props` option.
fix
Define the prop in the `props` object when creating your styled component, e.g., `const myProps = { myProp: String }; const MyComponent = styled('div', myProps)`.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vue-styled-components — npm install vue-styled-components · libregistry