Getting started
Four steps from an empty project to a themed component.
- 1
Install the package
Every component ships in
@c2n/components, one entry per component, so you only pay for what you import. Lit comes with it and is shared by all of them.npm install @c2n/components - 2
Import once, use anywhere
Importing a component's entry registers its
c2-*custom element. After that it is plain HTML.import '@c2n/components/text-field' // then anywhere in your markup <c2-text-field placeholder="Your email"></c2-text-field> - 3
Theme with CSS custom properties
Every visual detail is exposed as a variable named
--c2-<component>__<part>--<property>. Set them on any ancestor to restyle a component, a section, or the whole app. Or load @c2n/theme and set a handful of design tokens once..newsletter c2-text-field { --c2-text-field--border-top-left-radius: 12px; --c2-text-field--border-top-right-radius: 12px; --c2-text-field--border-bottom-left-radius: 12px; --c2-text-field--border-bottom-right-radius: 12px; --c2-text-field--background: #f4f4f5; --c2-text-field__focus--border-top: 1px solid #2563eb; --c2-text-field__focus--border-right: 1px solid #2563eb; --c2-text-field__focus--border-bottom: 1px solid #2563eb; --c2-text-field__focus--border-left: 1px solid #2563eb; } - 4
Extend with slots
Named slots let you replace icons and inject content without forking the component.
<c2-text-field placeholder="Search"> <svg slot="prefix-icon" viewBox="0 0 24 24">…</svg> </c2-text-field>