v 0.2.0

@reactiveProp

The @reactiveProp decorator creates a reactive property that automatically synchronizes with HTML attributes and triggers component updates when changed.

Usage

import { RadiantElement, customElement, reactiveProp } from '@ecopages/radiant';

@customElement('user-card')
export class UserCard extends RadiantElement {
	@reactiveProp({ type: String }) declare name: string;
	@reactiveProp({ type: Number, defaultValue: 0 }) declare age: number;
	@reactiveProp({ type: Boolean }) declare active: boolean;
}

Usage in HTML:

<user-card name="Alice" age="30" active></user-card>

Parameters

The decorator accepts an options object:

ParameterTypeRequiredDescription
typeAttributeTypeConstantYesString, Number, Boolean, Object, or Array.
reflectbooleanNoWhether to reflect changes back to the attribute (default: false).
attributestringNoCustom attribute name (default: property name in kebab-case).
defaultValueanyNoDefault value if the attribute is not present.

Supported Types

Reflection

Use the reflect option to keep the HTML attribute in sync with the property value. This is useful for styling elements based on their state using CSS attribute selectors.

@reactiveProp({ type: Boolean, reflect: true }) declare active: boolean;

Learn More